dourang6858 2019-03-20 19:15
浏览 44

在Eureka Server中,未在Spring中开发的服务/应用程序的发现和注册

How can web applications built without Spring (say, on Java-JEE and Go) be discovered and registered in Eureka Server ?

In a Spring-Boot application, it is easy to add these annotations:

@EnableDiscoveryClient
@SpringBootApplication

before

public class EurekaClientApp{
    public static void main(String[] args) {
        SpringApplication.run(EurekaClientApp.class, args);
    }
}

and in configuration, application.properties

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true

But for applications which were built not as Spring-Boot or for that matter as Microservices, how should they be discovered and registered as clients by Eureka Server

  • 写回答

1条回答 默认 最新

  • duanfu7004 2019-03-20 19:46
    关注

    It's like any other backend service; you have to use the right client. For example, if you have non-spring Java services, you could use;

    InstanceInfo nextServerInfo = DiscoveryManager.getInstance()
                    .getDiscoveryClient()
                    .getNextServerFromEureka(vipAddress, false);
    
            Socket s = new Socket();
            int serverPort = nextServerInfo.getPort();
            try {
                s.connect(new InetSocketAddress(nextServerInfo.getHostName(),
                        serverPort));
            } catch (IOException e) {
                System.err.println("Could not connect to the server :"
                        + nextServerInfo.getHostName() + " at port " + serverPort);
            }
    

    https://github.com/Netflix/eureka/wiki/Understanding-eureka-client-server-communication

    Here's a Python client;

    https://pypi.org/project/py-eureka-client/

    A golang client;

    https://github.com/hudl/fargo

    评论

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝