I have a DirectRabbitListenerContainer (created through a DirectRabbitListenerContainerFactory) where I have a MessageListener setup through a MessageListenerAdapter.
The issue I am have is that sometimes the same message from RabbitMQ will arrive at the MessageListener multiple times by different threads.
[2020-06-16 11:12:45,910] INFO com.something.MyMsgListener [pool-1-thread-3] Message ID:bca8cdcc-385a-4847-bd15-50e8936
[2020-06-16 11:12:45,910] INFO com.something.MyMsgListener [pool-1-thread-8] Message ID:bca8cdcc-385a-4847-bd15-50e8936
This is causing a lot of problems for the application I am writing. I am wondering if someone can point out which configuration item is causing this (or can prevent this). On the message producer side, I know only 1 message was produced and sent to RabbitMQ. Sometimes up to 6 threads will process the same message. Sometimes the problem goes away. I don't have a good grasp of why this is happening... any help would be greatly appreciated.
Thanks!
It's not possible, unless the listener called by pool-1-thread-3
throws an exception and the message is redelivered.
There is no guarantee that a redelivery will arrive on the same thread since it uses the thread pool managed by the amqp-client.
With the SimpleMessageListenerContainer
and concurrency=1
, the redeliveries will always occur on the same thread.