0

I used JHipster to generate a several microservices based on Spring Cloud Netflix. Currently thinking about adding Spring AMQP support in one of the services, using this tutorial: https://spring.io/guides/gs/messaging-rabbitmq/

When adding the AMQP support in the services, I found the service always register with the Registry(Eureka) server with status DOWN, and if i remove following gradle dependency the problem will go away

    compile('org.springframework.amqp:spring-rabbit:1.5.3.RELEASE')

The services with this dependency will first register with Eureka server with status UP at start up time, and then immediately re-register with status DOWN.

eureka registry server

The logs of Eureka server:

2016-08-26 06:55:18.291 INFO 5875 --- [io-8761-exec-11] c.n.e.registry.AbstractInstanceRegistry : Registered instance SALES/sales:4454c0adc6b9c70d799930ac3b7d374c with status STARTING (replication=false) 2016-08-26 06:55:18.806 INFO 5875 --- [io-8761-exec-10] c.n.e.registry.AbstractInstanceRegistry : Registered instance SALES/sales:4454c0adc6b9c70d799930ac3b7d374c with status STARTING (replication=true) 2016-08-26 06:55:21.260 INFO 5875 --- [nio-8761-exec-8] c.n.e.registry.AbstractInstanceRegistry : Registered instance SALES/sales:4454c0adc6b9c70d799930ac3b7d374c with status STARTING (replication=false) 2016-08-26 06:55:21.763 INFO 5875 --- [nio-8761-exec-1] c.n.e.registry.AbstractInstanceRegistry : Registered instance SALES/sales:4454c0adc6b9c70d799930ac3b7d374c with status STARTING (replication=true) 2016-08-26 06:55:37.220 INFO 5875 --- [nio-8761-exec-3] c.n.e.registry.AbstractInstanceRegistry : Registered instance SALES/sales:4454c0adc6b9c70d799930ac3b7d374c with status UP (replication=false) 2016-08-26 06:55:37.730 INFO 5875 --- [nio-8761-exec-2] c.n.e.registry.AbstractInstanceRegistry : Registered instance SALES/sales:4454c0adc6b9c70d799930ac3b7d374c with status UP (replication=true) 2016-08-26 06:55:37.885 INFO 5875 --- [io-8761-exec-11] c.n.e.registry.AbstractInstanceRegistry : Registered instance SALES/sales:4454c0adc6b9c70d799930ac3b7d374c with status DOWN (replication=false) 2016-08-26 06:55:38.399 INFO 5875 --- [nio-8761-exec-5] c.n.e.registry.AbstractInstanceRegistry : Registered instance SALES/sales:4454c0adc6b9c70d799930ac3b7d374c with status DOWN (replication=true) 2016-08-26 06:55:43.699 INFO 5875 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 2ms 2016-08-26 06:56:43.700 INFO 5875 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 2ms

On the other side, the log of the Sales service does not have any errors. however comparing with other services which do not have amqp dependency, the most significant difference in the log is

2016-08-26 06:55:37.881 WARN 6440 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator : Ignoring onDemand update due to rate limiter

I confirmed the issue will be fixed if i remove the spring amqp dependency.

Am I using the wrong amqp dependency? Is there any other way to use RabbitMQ in spring cloud microservices?

Tyler Shao
  • 156
  • 1
  • 10

1 Answers1

1
  1. In spring boot, when you add starter dependency like spring-amqp-starter,the framework will automatically configure the related properties to their default values.

  2. Discovery server such as Eureka use the URL (http://{service-ip}:{service-port}/health) to check the service health(availability),both ip and port are provided to Eureka during the deployment of the service, a call from service is done to the server to register itself.

  3. Here comes the trick, if your rabbit MQ server is not up and running on the configured IP or port,the response of health check will be "DOWN".

Conclusion : make sure that rabbit server up and running and any other components with thier dependencies in the class path(Redis, Couchbase and so on) and use the URL (http://{service-ip}:{service-port}/health) to check your service health, you should get something like this :

{ "description": "Spring Cloud Consul Discovery Client", "status": "UP" }

Shady Ragab
  • 705
  • 10
  • 26