[英]In Eureka Server, Discovey and Registration of Services/Applications NOT developed in Spring
如何在没有Spring(例如,在Java-JEE和Go上)构建的Web应用程序可以在Eureka Server中发现和注册?
在Spring-Boot应用程序中,可以轻松添加这些注释:
@EnableDiscoveryClient
@SpringBootApplication
之前
public class EurekaClientApp{
public static void main(String[] args) {
SpringApplication.run(EurekaClientApp.class, args);
}
}
在配置中,application.properties
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
但是对于那些不是像Spring-Boot那样构建的应用程序或者作为微服务构建的应用程序,它们应该如何被Eureka Server发现并注册为客户端
这就像任何其他后端服务; 你必须使用正确的客户 。 例如,如果您有非Spring Java服务,则可以使用;
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
这是一个Python客户端;
https://pypi.org/project/py-eureka-client/
一个golang客户;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.