2
votes

Hello I have RabbitMQ queue created from application A. I want to get messages from that queue so I have created message listener in spring boot application using this dependency:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-amqp</artifactId>
    </dependency>

After that i make this scenario: 1. Start the spring boot app 2. Send a message to the queue

The problem is that the first two messages are not being listened from the listener. So that is why i create a message listener in Java only but I have got the same problem. In RabbitMQ management I can see that the message has been published and not consumed... I have tried many different configurations but non of that succeeded. When I create a queue manually everything its working correctly. So I have a doubt that the application A is not creating the queue correctly or with some arguments (even though in RabbitMQ manager the Args policy does not stay near the name of the queue)

The message properties from succesffully consumed message: These are the message properties of successfully consumed message:

MessageProperties [headers={}, correlationId= TODO_requestID, replyTo=ME, contentType=application/json, contentLength=0, redelivered=false, receivedExchange=me-exchange, receivedRoutingKey=from-me, deliveryTag=1, consumerTag=amq.ctag-vPDSoiCHmWcb0v0NrINbIg, consumerQueue=from-me])
1
Is it a race condition? Are you starting the producer before the consumer? - Software Engineer
The consumer and the producer are in the same app. But I am publishing messages manually from the rabbitMq management. - xmlParser
I have commented all the configs and usages of the publisher and its same :) - xmlParser
I see - have you given the service enough time to properly startup and register its listener before you start sending messages manually? - Software Engineer
Yes i publish message after 1 or 2 minutes :) - xmlParser

1 Answers

4
votes

Go to the RabbitMQ Mannagment open the queue and check if there are other consumers. Maybe some other consumers are collecting the first two messages.

I have faced a similar problem..