簡體   English   中英

在Eureka服務器,Discovey和服務/應用程序的注冊不是在Spring開發的

[英]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客戶;

https://github.com/hudl/fargo

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM