Using Hystrix Stream in Zuul with Eureka First to find Config server - spring

I'm using spring cloud Brixton.M4 with spring boot 1.3.1
I have zuul server with
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-hystrix-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
and i'm using Eureka first to find Config-Server so bootstrap looks like
spring:
profiles: dev
cloud:
config:
fail-fast: true
discovery:
enabled: true
serviceId: config-server
zuul is registring two time first with UP state then with STARTING
2016-01-18 14:47:27.209 INFO 2808 --- [ main] c.w.i.edgeserver.EdgeServerApplication : Started EdgeServerApplication in 21.651 seconds (JVM running for 22.232)
2016-01-18 14:47:56.231 INFO 2808 --- [ool-20-thread-1] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003 - Re-registering apps/EDGE-SERVER
2016-01-18 14:47:56.270 INFO 2808 --- [ool-20-thread-1] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003: registering service...
2016-01-18 14:47:56.281 INFO 2808 --- [ool-20-thread-1] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003 - registration status: 204
2016-01-18 14:48:06.230 INFO 2808 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003: registering service...
2016-01-18 14:48:06.238 INFO 2808 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003 - registration status: 204
If I remove dependency on config-server by setting
spring:
profiles: dev
cloud:
config:
fail-fast: false
discovery:
enabled: false
serviceId: config-server
everything runs fine.

That's normal I think (the bootstrap phase has to register to get the configserver location, and then unregister to let the main application register again). You will probably find that it settles back to UP after the application has started up fully.

Related

Running Spring Boot Admin with a non-default port

I want to start the Spring Boot Admin server on a different port than 8080.
So I configured the server.port property in the bootstrap.yml file with 9000, but still the server listens on port 8080 according to the log file.
Here's my bootstrap.yml:
server:
port: 9000
spring:
application:
name: admin-server
cloud:
config:
uri: http://localhost:8888
And this is the final part of the console log:
2018-11-29 15:52:11.242 INFO 25999 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-11-29 15:52:11.271 INFO 25999 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-11-29 15:52:11.274 INFO 25999 --- [ main] n.d.d.c.a.AdminServerApplication : Started AdminServerApplication in 2.826 seconds (JVM running for 3.355)
2018-11-29 15:52:11.818 INFO 25999 --- [on(4)-127.0.0.1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-11-29 15:52:11.819 INFO 25999 --- [on(4)-127.0.0.1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-11-29 15:52:11.830 INFO 25999 --- [on(4)-127.0.0.1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 11 ms
In the application.properties file put this
server.port = 9000
A flashlight in my brain told me I might have forgotten to add the spring-cloud-config-client dependency, after checking, and then adding the appropriate dependency to the pom.xml, it worked like a charm:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
Thanks to all for providing feedback.
Many different configuration sources have precedence over application.properties (or YAML) as described here: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
You might need to verify if one of those sources are not interfering with the value of serve.port.

Why deploying the jHipster .war application to Tomcat 8 server keeps restarting application?

I've developed simple jHipster microservice and I'm trying to run it on Tomcat 8 server. It seems that tomcat is starting new instance of service after one is loaded, up and running.
I'm running web app as production app.
spring:
devtools:
restart:
enabled: false
livereload:
enabled: false
After couple instance is started server crashes.
Edit ( Please see log between one instance is deployed and another is starting up
2017-09-17 18:28:22.472 INFO 16950 --- [ost-startStop-1] pl.kx7.fb.pages.ApplicationWebXml : Started ApplicationWebXml in 52.059 seconds (JVM running for 66.585)
17-Sep-2017 18:28:22.610 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/opt/tomcat/webapps/pagesmanager-1.0.1-SNAPSHOT.war] has finished in [64,878] ms
17-Sep-2017 18:28:22.611 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/tomcat/webapps/pm]
2017-09-17 18:28:31.973 INFO 16950 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2017-09-17 18:28:31.973 INFO 16950 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2017-09-17 18:28:31.973 INFO 16950 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2017-09-17 18:28:31.974 INFO 16950 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application is null : false
2017-09-17 18:28:31.974 INFO 16950 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2017-09-17 18:28:31.974 INFO 16950 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application version is -1: false
2017-09-17 18:28:31.975 INFO 16950 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2017-09-17 18:28:32.077 INFO 16950 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : The response status is 200
[jHipster logo]
:: JHipster đ¤ :: Running Spring Boot 1.5.4.RELEASE ::
:: https://jhipster.github.io ::
2017-09-17 18:28:41.559 INFO 16950 --- [ost-startStop-1] pl.kx7.fb.pages.ApplicationWebXml : The following profiles are active: prod
2017-09-17 18:28:46.559 DEBUG 16950 --- [ost-startStop-1] p.k.fb.pages.config.AsyncConfiguration : Creating Async Task Executor
^C2017-09-17 18:28:46.722 WARN 16950 --- [ Thread-9] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1505665726722, current=DOWN, previous=UP]
Edit 2
It seems that problem is appearing after I've confiugured host for my app:
<Host name="pm.myhost.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Alias>pm.myhost.com</Alias>
<Context path="" docBase="/opt/tomcat/webapps/pm" reloadable="true">
</Context>
</Host>

Eureka server and eureka client to separate tomcat servers

I'm looking for a way to be able to deploy the Eureka server to a different tomcat server than the Eureka client.
this is the client application.yml:
eureka:
client:
registryFetchIntervalSeconds: 5
instance:
preferIpAddress: true
leaseRenewalIntervalInSeconds: 10
server:
port: 8080
spring:
application.name: my-client
jmx:
default-domain: my-client
and the server application.yml looks like:
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
It works perfectly fine if I deploy them to the same tomcat-server. But if I start the tomcat with the server only and later start the server with the client, I get the following error:
2017-03-09 16:17:58.496 INFO 7693 --- [on(2)-127.0.0.1] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2017-03-09 16:17:58.496 INFO 7693 --- [on(2)-127.0.0.1] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2017-03-09 16:17:58.496 INFO 7693 --- [on(2)-127.0.0.1] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2017-03-09 16:18:04.740 WARN 7693 --- [on(2)-127.0.0.1] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failure with status code 404; retrying on another server if available
2017-03-09 16:18:04.745 ERROR 7693 --- [on(2)-127.0.0.1] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MYCLIENT-CLIENT/192.168.196.141:my-client:8080 - was unable to refresh its cache! status = Cannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.4.12.jar:1.4.12]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[eureka-client-1.4.12.jar:1.4.12]
What is the difference between bootstrap.yml and application.yml?
Any help would be appreciated!
your client application.yml dosen't have information about where your eureka server is running.client should register with eureka server, for that you need to configure your client application.yml as follow
eureka:
client:
serviceUrl:
defaultZone:http:localhost:8081/eureka/
instance:
instanceId:application_name:${random.value}

SpringBoot App Registers UNKNOWN with Eureka in Brixton SR3

I'm running Spring Cloud Brixton SR3 - Spring Netflix Eureka, Spring Cloud Config and a Discovery Client app. When the client app is configured with
eureka.client.healthcheck.enabled=true
and
spring.cloud.config.discovery.enabled=true
the app starts up registered with Eureka with a status of "UNKNOWN" and never changes to "UP". If either of those flags is set to false then the app starts up registered as "UP".
I see this series of logging when both flags are enabled/true:
2016-07-13 17:41:38.144 INFO 13180 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1468456898144, current=UP, previous=STARTING]
2016-07-13 17:41:38.144 DEBUG 13180 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator : Executing on-demand update of local InstanceInfo
2016-07-13 17:41:38.144 DEBUG 13180 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator : Canceling the latest scheduled update, it will be rescheduled at the end of on demand update
2016-07-13 17:41:38.145 INFO 13180 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1468456898145, current=UNKNOWN, previous=UP]
How do I get the app to register as UP with both of these flags enabled/true?
bootstrap.yml
spring:
application:
name: hello-brixton
# Spring Cloud Config
cloud:
config:
name: hello-brixton
discovery:
enabled: true
serviceId: config-service
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: ${SERVICE_REGISTRY_URL:http://localhost:8080/eureka/}
healthcheck:
enabled: true
I know this was asked a long time ago, but I just ran into the same problem and this was the only questions that directly matched my issue.
I am using Camden.SR2, and if you find the section Eureka’s Health Checks in the reference documentation you will see the following warning:
eureka.client.healthcheck.enabled=true should only be set in
application.yml. Setting the value in bootstrap.yml will cause
undesirable side effects like registering in eureka with an UNKNOWN
status.
That's exactly the problem. If you shift the setting of the property to the application.yml file it all works as expected.

In Eureka First Bootstrap mode if client starts on a random port number, its registring with port 0

I'm using spring cloud Brixton.M4 and spring boot is v1.3.1, with eureka first approach and application starts on random port server.port=0 but its register it self at port 0 with eureka server.
here is my bootstrap.properties file
server.port=0
spring.application.name=course-composite-service
spring.cloud.config.fail-fast=true
spring.cloud.config.label=config-dev
spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.serviceId=config-server
eureka.client.serviceUrl.defaultZone=http://localhost:8002/eureka/
and below its the log
2016-01-11 18:36:50.286 INFO 17233 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_COURSE-COMPOSITE-SERVICE/192.168.17.178:course-composite-service:0: registering service...
2016-01-11 18:36:50.288 INFO 17233 --- [ main] .w.c.c.CourseCompositeServiceApplication : Started CourseCompositeServiceApplication in 5.325 seconds (JVM running for 5.856)
2016-01-11 18:36:50.321 INFO 17233 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_COURSE-COMPOSITE-SERVICE/192.168.17.178:course-composite-service:0 - registration status: 204
and eureka dashboard shows
COURSE-COMPOSITE-SERVICE UP (1) - 192.168.17.178:course-composite-service:0
why its not registering with the actual port its running?
i'm providing other eureka configurations from the Config Sever they are
eureka.client.register-with-eureka=true
eureka.instance.leaseRenewalIntervalInSeconds=10
eureka.instance.leaseExpirationDurationInSeconds=5
eureka.instance.preferIpAddress=false
eureka.instance.metadataMap.hostname=${vcap.application.application_uris[0]}
eureka.instance.metadataMap.instanceId=${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${random.value}}}

Resources