Git Product home page Git Product logo

service-registration-and-discovery's Introduction

service-to-service-calls-with-spring-cloud

A repository for a blog on how Spring Cloud promotes resilient service-to-service calls through service registries and service discovery

service-registration-and-discovery's People

Contributors

joshlong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

service-registration-and-discovery's Issues

Services are unable to reach Eureka

Hi!

I'm running local CF in Vagrant, (domain is 10.244.0.34.xip.io ), and I see that services are failing to connect each other, like:

2015-07-17T11:56:01.94+0300 [App/0]      OUT 2015-07-17 08:56:01.945 ERROR 33 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://config.10.244.0.34.xip.io/eureka/cloud":Connection refused; nested exception is java.net.ConnectException: Connection refused
a

(but if I do "curl http://config.10.244.0.34.xip.io/eureka/cloud" inside this vagrant VM I'm getting right response)

Do you have any idea why?

Could not resolve host: peer1-service but could see in eureka dashboard

Hi,

We are refactoring existing monolithic based application to micro-services and we decided to use the following spring cloud (Netflix) version and end up with "Could not resolve host: peer1-service" on curl for registered micro service with "spring:application:name: peer1-service".

Could some one help me here please as I struck up with this for a long time by spending on google and trying different ways...

JDK 8
Spring boot 2.0.0.RELEASE
Spring cloud: Finchley.M8

  1. Eureka Server with below configuration (Also annotated with @EnableEurekaServer):

spring:
application:
name: eureka-service

eureka:
client:
register-with-eureka: false
fetch-registry: false
server:
wait-time-in-ms-when-sync-empty: 0

  1. peer1-service & peer2-service has same configurations except service name & port

spring:
application:
name: peer1-service

server:
port: 8282

eureka:
instance:
hostname: localhost
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8080/eureka

This issue has come up when I start using service name which register with eureka discovery service where as if I use localhost instead of peer1-service / peer2-service, its working fine. Then I understood that something went wrong with discovery of service based on the name what I provided in application.yaml

The logs for reference (Same as for peer2-service)...

  1. Eureka Server logs:

2018-03-07 23:37:10.551 WARN 7327 --- [nio-8080-exec-2] c.n.e.registry.AbstractInstanceRegistry : DS: Registry: lease doesn't exist, registering resource: PEER1-SERVICE - venkatas-mbp:peer1-service:8282
2018-03-07 23:37:10.551 WARN 7327 --- [nio-8080-exec-2] c.n.eureka.resources.InstanceResource : Not Found (Renew): PEER1-SERVICE - venkatas-mbp:peer1-service:8282
2018-03-07 23:37:10.587 INFO 7327 --- [nio-8080-exec-3] c.n.e.registry.AbstractInstanceRegistry : Registered instance PEER1-SERVICE/venkatas-mbp:peer1-service:8282 with status UP (replication=false)
2018-03-07 23:37:10.587 INFO 7327 --- [nio-8080-exec-4] c.n.e.registry.AbstractInstanceRegistry : Registered instance PEER1-SERVICE/venkatas-mbp:peer1-service:8282 with status UP (replication=false)
2018-03-07 23:37:11.139 ERROR 7327 --- [get_localhost-1] c.n.e.cluster.ReplicationTaskProcessor : Network level connection to peer localhost; retrying after delay

com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused)
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
at com.netflix.eureka.cluster.DynamicGZIPContentEncodingFilter.handle(DynamicGZIPContentEncodingFilter.java:48) ~[eureka-core-1.8.6.jar:1.8.6]

  1. PEER2-SERVICE log trace (same as PEER1-SERVICE)

2018-03-07 23:37:16.343 INFO 7324 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EUREKA2-SERVICE/venkatas-mbp:eureka2-service:8181 - Re-registering apps/EUREKA2-SERVICE
2018-03-07 23:37:16.343 INFO 7324 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EUREKA2-SERVICE/venkatas-mbp:eureka2-service:8181: registering service...
2018-03-07 23:37:16.357 INFO 7324 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : The response status is 200
2018-03-07 23:37:16.392 INFO 7324 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EUREKA2-SERVICE/venkatas-mbp:eureka2-service:8181 - registration status: 204
2018-03-07 23:37:16.392 INFO 7324 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EUREKA2-SERVICE/venkatas-mbp:eureka2-service:8181 - registration status: 204
2018-03-07 23:37:46.362 INFO 7324 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2018-03-07 23:37:46.362 INFO 7324 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2018-03-07 23:37:46.362 INFO 7324 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2018-03-07 23:37:46.362 INFO 7324 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application is null : false
2018-03-07 23:37:46.362 INFO 7324 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2018-03-07 23:37:46.362 INFO 7324 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application version is -1: false
2018-03-07 23:37:46.362 INFO 7324 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2018-03-07 23:37:46.395 INFO 7324 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : The response status is 200

passport service not registering with Eureka

I cloned this git repo.
I did mvn clean install in the top-level project

and executed the following commands in order

java -jar eureka-service.jar

java -jar bookmark-service.jar

java -jar photo-service.jar

java -jar passport-service.jar

bookmark-service and photo-service registers sucessfully with Eureka. I can confirm this with logs and the Eueka UI that lists all instances registered with Eureka.

However, passport-service registration fails. Here are the logs:

output in passport-service log:

2015-08-19 14:10:07.142  INFO 5070 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@11063673: startup date [Wed Aug 19 14:10:03 PDT 2015]; root of context hierarchy
2015-08-19 14:10:07.142  INFO 5070 --- [       Thread-4] c.n.l.DynamicServerListLoadBalancer      : Shutting down the Executor Pool for DynamicServerListLoadBalancer
2015-08-19 14:10:07.142  INFO 5070 --- [       Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@651c807b: startup date [Wed Aug 19 14:10:04 PDT 2015]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@11063673
2015-08-19 14:10:07.143  INFO 5070 --- [       Thread-3] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 0
2015-08-19 14:10:07.155  INFO 5070 --- [       Thread-3] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_PASSPORT-SERVICE/local.registerdisney.go.com - deregister  status: 404
2015-08-19 14:10:07.156  INFO 5070 --- [       Thread-3] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2015-08-19 14:10:07.156  INFO 5070 --- [       Thread-3] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans
2015-08-19 14:10:07.157  INFO 5070 --- [       Thread-3] c.n.e.EurekaDiscoveryClientConfiguration : Closing DiscoveryClient.jerseyClient
2015-08-19 14:10:07.158  INFO 5070 --- [       Thread-3] c.n.e.EurekaDiscoveryClientConfiguration : Removing application passport-service from eureka
2015-08-19 14:10:07.162  INFO 5070 --- [       Thread-3] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_PASSPORT-SERVICE/local.registerdisney.go.com - deregister  status: 404

output in Eureka-service log:

2015-08-19 14:07:15.642  INFO 4741 --- [hresholdUpdater] c.n.eureka.PeerAwareInstanceRegistry     : Current renewal threshold is : 1
2015-08-19 14:10:07.151  WARN 4741 --- [nio-8761-exec-7] com.netflix.eureka.InstanceRegistry      : DS: Registry: cancel failed because Lease is not registered for: PASSPORT-SERVICE:local.registerdisney.go.com
2015-08-19 14:10:07.151  INFO 4741 --- [nio-8761-exec-7] c.n.eureka.resources.InstanceResource    : Not Found (Cancel): PASSPORT-SERVICE - local.registerdisney.go.com
2015-08-19 14:10:07.160  WARN 4741 --- [nio-8761-exec-1] com.netflix.eureka.InstanceRegistry      : DS: Registry: cancel failed because Lease is not registered for: PASSPORT-SERVICE:local.registerdisney.go.com
2015-08-19 14:10:07.160  INFO 4741 --- [nio-8761-exec-1] c.n.eureka.resources.InstanceResource    : Not Found (Cancel): PASSPORT-SERVICE - local.registerdisney.go.com
2015-08-19 14:12:15.657  INFO 4741 --- [eerNodesUpdater] c.n.eureka.PeerAwareInstanceRegistry     : Adding replica node: http://localhost:8761/eureka/
2015-08-19 14:17:15.675  INFO 4741 --- [hresholdUpdater] c.n.eureka.PeerAwareInstanceRegistry     : Current renewal threshold is : 1

After I shutdown photo-service, I see the following error in

2015-08-19 14:27:15.706  INFO 4741 --- [hresholdUpdater] c.n.eureka.PeerAwareInstanceRegistry     : Current renewal threshold is : 1
2015-08-19 14:27:23.452  INFO 4741 --- [nio-8761-exec-5] c.n.eureka.resources.InstanceResource    : Found (Cancel): PHOTO-SERVICE - local.registerdisney.go.com
2015-08-19 14:27:23.461  WARN 4741 --- [nio-8761-exec-2] com.netflix.eureka.InstanceRegistry      : DS: Registry: cancel failed because Lease is not registered for: PHOTO-SERVICE:local.registerdisney.go.com
2015-08-19 14:27:23.461  INFO 4741 --- [nio-8761-exec-2] c.n.eureka.resources.InstanceResource    : Not Found (Cancel): PHOTO-SERVICE - local.registerdisney.go.com
2015-08-19 14:27:23.462  WARN 4741 --- [-Cancel-process] c.netflix.eureka.cluster.PeerEurekaNode  : The replication of PHOTO-SERVICE/local.registerdisney.go.com/Cancel failed with response code 404
2015-08-19 14:27:23.462  WARN 4741 --- [-Cancel-process] c.netflix.eureka.cluster.PeerEurekaNode  : PeerEurekaNode: http://localhost:8761/eureka/apps/: PHOTO-SERVICE/local.registerdisney.go.com : delete: missing entry.

I also tried running
mvn spring-boot:run in each of the modules in same order above. I still see passport-service not registering with Eureka.

Deployment to run.pivotal.io fails

I am running the cf.sh script and all the services get created successfully. But the passport service fails to start correctly. In the logs I actually see it come up, but it shuts down right away:

[...]
2015-03-10T11:18:27.31+0100 [App/0]      OUT    XADataSourceAutoConfiguration
2015-03-10T11:18:27.32+0100 [App/0]      OUT 2015-03-10 10:18:27.325  INFO 31 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@170195ea: startup date [Tue Mar 10 10:18:27 UTC 2015]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@6f7c6c88
2015-03-10T11:18:27.61+0100 [App/0]      OUT 2015-03-10 10:18:27.619  INFO 31 --- [           main] c.netflix.config.ChainedDynamicProperty  : Flipping property: bookmark-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2015-03-10T11:18:27.68+0100 [App/0]      OUT 2015-03-10 10:18:27.681  INFO 31 --- [           main] c.netflix.loadbalancer.BaseLoadBalancer  : Client:bookmark-service instantiated a LoadBalancer:DynamicServerListLoadBalancer:{NFLoadBalancer:name=bookmark-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2015-03-10T11:18:27.71+0100 [App/0]      OUT 2015-03-10 10:18:27.714  INFO 31 --- [           main] c.netflix.config.ChainedDynamicProperty  : Flipping property: bookmark-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2015-03-10T11:18:27.71+0100 [App/0]      OUT 2015-03-10 10:18:27.718  INFO 31 --- [           main] c.n.l.DynamicServerListLoadBalancer      : DynamicServerListLoadBalancer for client bookmark-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=bookmark-service,current list of Servers=[bookmark-service-nonbiographical-disafforestment.cfapps.io:80],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone;   Instance count:1;   Active connections count: 0;    Circuit breaker tripped count: 0;   Active connections per server: 0.0;]
2015-03-10T11:18:27.71+0100 [App/0]      OUT },Server stats: [[Server:bookmark-service-nonbiographical-disafforestment.cfapps.io:80;    Zone:defaultZone;   Total Requests:0;   Successive connection failure:0;    Total blackout seconds:0;   Last connection made:Thu Jan 01 00:00:00 UTC 1970;  First connection made: Thu Jan 01 00:00:00 UTC 1970;    Active Connections:0;   total failure count in last (1000) msecs:0; average resp time:0.0;  90 percentile resp time:0.0;    95 percentile resp time:0.0;    min resp time:0.0;  max resp time:0.0;  stddev resp time:0.0]
2015-03-10T11:18:27.71+0100 [App/0]      OUT ]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@7cb78143
2015-03-10T11:18:27.79+0100 [App/0]      OUT 2015-03-10 10:18:27.790  INFO 31 --- [           main] com.netflix.http4.ConnectionPoolCleaner  : Initializing ConnectionPoolCleaner for NFHttpClient:bookmark-service
2015-03-10T11:18:27.86+0100 [App/0]      OUT 2015-03-10 10:18:27.864  INFO 31 --- [           main] com.netflix.http4.ConnectionPoolCleaner  : Initializing ConnectionPoolCleaner for NFHttpClient:bookmark-service
2015-03-10T11:18:28.12+0100 [App/0]      OUT Bookmark{id=2, href='http://some-other-hostjlong.com/', label='jlong', description='A description for jlong's link', userId='jlong'}
2015-03-10T11:18:28.15+0100 [App/0]      OUT Bookmark{id=1, href='http://some-other-hostmstine.com/', label='mstine', description='A description for mstine's link', userId='mstine'}
2015-03-10T11:18:28.18+0100 [App/0]      OUT org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient$EurekaServiceInstance@4e1231a5[instance=com.netflix.appinfo.InstanceInfo@b8ee954f]
2015-03-10T11:18:28.18+0100 [App/0]      OUT org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient$EurekaServiceInstance@68019ddf[instance=com.netflix.appinfo.InstanceInfo@116b67da]
2015-03-10T11:18:28.18+0100 [App/0]      OUT 2015-03-10 10:18:28.182  INFO 31 --- [           main] passport.Application                     : Started Application in 6.954 seconds (JVM running for 7.874)
2015-03-10T11:18:28.18+0100 [App/0]      OUT 2015-03-10 10:18:28.183  INFO 31 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6c9c8d26: startup date [Tue Mar 10 10:18:22 UTC 2015]; root of context hierarchy
2015-03-10T11:18:28.18+0100 [App/0]      OUT 2015-03-10 10:18:28.184  INFO 31 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6f7c6c88: startup date [Tue Mar 10 10:18:23 UTC 2015]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@6c9c8d26
2015-03-10T11:18:28.18+0100 [App/0]      OUT 2015-03-10 10:18:28.186  INFO 31 --- [       Thread-2] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 0
2015-03-10T11:18:28.18+0100 [App/0]      OUT 2015-03-10 10:18:28.189  INFO 31 --- [       Thread-4] c.n.l.DynamicServerListLoadBalancer      : Shutting down the Executor Pool for DynamicServerListLoadBalancer
2015-03-10T11:18:28.23+0100 [App/0]      OUT 2015-03-10 10:18:28.230  INFO 31 --- [       Thread-2] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_PASSPORT-SERVICE/passport-service-imbibitional-pinetum.cfapps.io - deregister  status: 404
[...]

The eureka services seems fine, although it is hard to tell since its log output is dominated by its failing attempts to connect to the replica server running on localhost. Is that maybe relevant to the failure of the passport app?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.