Search code examples
javarabbitmqconsumer

RabbitMQ Consumer error message


My RabbitMQ server is running perfectly. Check below for ports and ip.

C:\Users\parmarc>netstat -ano | find "5672"
  TCP    0.0.0.0:5672           0.0.0.0:0              LISTENING       2704
  TCP    0.0.0.0:15672          0.0.0.0:0              LISTENING       2704
  TCP    0.0.0.0:55672          0.0.0.0:0              LISTENING       2704
  TCP    127.0.0.1:5672         127.0.0.1:61775        ESTABLISHED     2704
  TCP    127.0.0.1:15672        127.0.0.1:57671        ESTABLISHED     2704
  TCP    127.0.0.1:57671        127.0.0.1:15672        ESTABLISHED     8408
  TCP    127.0.0.1:61775        127.0.0.1:5672         ESTABLISHED     10312
  TCP    [::]:5672              [::]:0                 LISTENING       2704

I keep getting following error regarding consumer. I am able to push things into RabbitMQ but not able to consume because of this error.

WARN : org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer - 
       Consumer raised exception, processing can restart if the connection factory supports it. 
       Exception summary: org.springframework.amqp.AmqpIOException: java.net.UnknownHostException: 127.0.0.1
INFO : org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer - 
       Restarting Consumer: tag=[null], channel=null, acknowledgeMode=AUTO 
       local queue size=0

Below is my mq-Config.properties file:

server.host=127.0.0.1   
server.port=5672
search.service.vmhost=/
search.service.username=guest
search.service.password=guest


search.service.indexwriter.queue.name=search.service.indexwriter.queue.test
search.service.indexwriter.exchange.name=search.service.indexwriter.exchange.test
search.service.indexwriter.routing.key=search.service.indexwriter.routing.test
numberof.concurrentconsumer=10
max.failure.retry.attempts=3

Below is my mq-Config-consumer.properties file:

#######Consumer Properties######
retailer.syncservice.consumer.server.host=127.0.0.1
retailer.syncservice.consumer.server.port=5672
retailer.syncservice.consumer.service.vmhost=/
retailer.syncservice.consumer.service.username=guest
retailer.syncservice.consumer.service.password=guest
retailer.syncservice.consumer.queue.name=retailer.syncservice.queue.fanoutqueue.test
retailer.syncservice.consumer.exchange.name=retailer.consumer.direct.exchange.test
retailer.syncservice.consumer.routing.key=retailer.consumer.routingkey.test
numberof.concurrentconsumer=10

Can anybody suggest what is wrong with the consumer setup? I tried googling it but did not find satisfactory answer which solves my issue. So asking it here.


Solution

  • I solved it with the help of my colleague. It was really a silly mistake.

    Tab Character after value in properties file

    There was a after 127.0.0.1 in mq-Config.properties file:

    server.host = 127.0.0.1#tab character was here

    Because of that it was not able to connect. I guess rabbitMQ is not trimming things from properties file. So even if there is a space after your value it will behave unexpectedly.

    I removed tab character.

    server.host = 127.0.0.1

    After that it worked.