具有Wildfly和部署顺序的Eureka + Cloud-Config

时间:2018-06-22 10:46:11

标签: java spring-boot wildfly netflix-eureka spring-cloud-config

我需要在Wildfly环境中集成一些SpringBoot服务。 在野外有一个作为WAR运行的Eureka-Server + Cloud Config-Service。我看不到仪表板,但可以在..eureka / apps的XML数据中看到自我注册的服务 如果我以独立模式启动用于Eureka / Cloud Config的SpringBoot客户端-它会完美连接到此Wildfly / Eureka / CloudConfig服务。同样,当我将此客户端作为WAR添加到已经运行的Wildfly / Eureka / CloudConfig系统中时。

但是当我终止服务器并重新启动服务器时,两个WAR的并行部署在启动过程中当然会产生很多异常。可以,因为Eureka服务器尚未启动。但是之后-客户端将自己正确注册到Eureka服务器(我再次在eureka / apps中看到了它)。但是客户端始终会发送异常。

2018-06-22 12:40:10,345 WARN  [org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration] (DiscoveryClient-CacheRefreshExecutor-0) Could not locate configserver via discovery: java.lang.IllegalStateException: No instances found of configserver (EUREKA-DISCOVERY-SERVICE)
        at org.springframework.cloud.config.client.ConfigServerInstanceProvider.getConfigServerInstance(ConfigServerInstanceProvider.java:25)
        at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration.refresh(DiscoveryClientConfigServiceBootstrapConfiguration.java:80)
        at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration.heartbeat(DiscoveryClientConfigServiceBootstrapConfiguration.java:72)
        at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:261)
        at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:180)
        at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:142)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:406)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354)
        at org.springframework.cloud.netflix.eureka.CloudEurekaClient.onCacheRefreshed(CloudEurekaClient.java:112)
        at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:981)
        at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1471)
        at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1438)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

每30秒(刷新时间)出现一次异常。 我不明白,为什么会这样。 ... eureka / apps结果显示了服务

<applications>
  <versions__delta>1</versions__delta>
  <apps__hashcode>UP_2_</apps__hashcode>
  <application>
    <name>EUREKA-DISCOVERY-SERVICE</name>
    <instance>
      <instanceId>192.168.207.94:eureka-discovery-service:8443</instanceId>
      <hostName>localhost</hostName>
      <app>EUREKA-DISCOVERY-SERVICE</app>
      <ipAddr>192.168.207.94</ipAddr>
      <status>UP</status>
      <overriddenstatus>UNKNOWN</overriddenstatus>
      <port enabled="false">80</port>
      <securePort enabled="true">8443</securePort>
      <countryId>1</countryId>
      <dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
        <name>MyOwn</name>
      </dataCenterInfo>
      <leaseInfo>
        <renewalIntervalInSecs>30</renewalIntervalInSecs>
        <durationInSecs>90</durationInSecs>
        <registrationTimestamp>1529662231729</registrationTimestamp>
        <lastRenewalTimestamp>1529663993904</lastRenewalTimestamp>
        <evictionTimestamp>0</evictionTimestamp>
        <serviceUpTimestamp>1529662210687</serviceUpTimestamp>
      </leaseInfo>
      <metadata>
        <management.port>8443</management.port>
        <configPath>/eureka-ds/config</configPath>
      </metadata>
      <homePageUrl>http://localhost:80/</homePageUrl>
      <statusPageUrl>http://localhost:8443/actuator/info</statusPageUrl>
      <healthCheckUrl>http://localhost:8443/actuator/health</healthCheckUrl>
      <secureHealthCheckUrl>https://localhost:8443/actuator/health</secureHealthCheckUrl>
      <vipAddress>eureka-discovery-service</vipAddress>
      <secureVipAddress>eureka-discovery-service</secureVipAddress>
      <isCoordinatingDiscoveryServer>true</isCoordinatingDiscoveryServer>
      <lastUpdatedTimestamp>1529662231729</lastUpdatedTimestamp>
      <lastDirtyTimestamp>1529662193289</lastDirtyTimestamp>
      <actionType>ADDED</actionType>
    </instance>
  </application>
  <application>
    <name>MARK2</name>
    <instance>
      <instanceId>192.168.207.94:mark2:9998</instanceId>
      <hostName>192.168.207.94</hostName>
      <app>MARK2</app>
      <ipAddr>192.168.207.94</ipAddr>
      <status>UP</status>
      <overriddenstatus>UNKNOWN</overriddenstatus>
      <port enabled="true">9998</port>
      <securePort enabled="false">443</securePort>
      <countryId>1</countryId>
      <dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
        <name>MyOwn</name>
      </dataCenterInfo>
      <leaseInfo>
        <renewalIntervalInSecs>30</renewalIntervalInSecs>
        <durationInSecs>90</durationInSecs>
        <registrationTimestamp>1529662210686</registrationTimestamp>
        <lastRenewalTimestamp>1529663979339</lastRenewalTimestamp>
        <evictionTimestamp>0</evictionTimestamp>
        <serviceUpTimestamp>1529662210687</serviceUpTimestamp>
      </leaseInfo>
      <metadata>
        <management.port>9998</management.port>
        <configPath>/eureka-ds/config</configPath>
        <user>user</user>
        <password>software1</password>
      </metadata>
      <homePageUrl>http://192.168.207.94:9998/</homePageUrl>
      <statusPageUrl>http://192.168.207.94:9998/actuator/info</statusPageUrl>
      <healthCheckUrl>http://192.168.207.94:9998/actuator/health</healthCheckUrl>
      <vipAddress>mark2</vipAddress>
      <secureVipAddress>mark2</secureVipAddress>
      <isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
      <lastUpdatedTimestamp>1529662210687</lastUpdatedTimestamp>
      <lastDirtyTimestamp>1529662208806</lastDirtyTimestamp>
      <actionType>ADDED</actionType>
    </instance>
  </application>
</applications>

2 个答案:

答案 0 :(得分:0)

我找到了一种使它工作的方法。

  • 如果我设置spring.cloud.config.fail-fast = false(这是默认设置),则该服务将进行多次重试。然后,在引导过程中,服务将发送错误,但是在配置服务器启动后,客户端服务将注册并且一切正常。这需要几秒钟...
  • 然后-我了解到,不要将Eureka服务器和Cloud config服务器放在一项服务中。即使减少基础架构的最小化是一个好主意,但云配置服务还是有点麻烦,并且需要对URL路径的完全访问权限。由于存在一个小错误(存在拉取请求),即使定义前缀也不能真正起作用。
  • 第三-在Wildfly环境中正确定义StatusPageURLPath和HealthCheckURLPath(见上文,这是错误的)

答案 1 :(得分:0)

此答案可能有助于解决错误 No instances found of configserver(configserver)

Spring Cloud Config Server的默认名称为“ configserver”。如果使用spring.application.name=my-config-server中的application.properties覆盖此名称,则在Config Client应用程序的bootstrap.properties中,您需要使用{{ 1}}

示例配置服务器

spring.cloud.config.discovery.service-id=my-config-server

样本配置客户端

spring.application.name=my-config-server
eureka.instance.hostname=localhost
server.port=8888
spring.cloud.config.server.git.uri=file:////Users/asadhat/work/lab/spring-cloud
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/