GMelo
GMelo

Reputation: 231

Acknowledging rabbitMq messages from different threads in Java

I have a multi- tiered worker pattern implementation using rabbit to distribute the task, so messages come in via one of many "listners"( a executor service with many threads calling consumer.basicConsume(), each with its own Channel). The messages get passed around the application and then at the final stage they are picked up by an ack listener(again, running out of its own ExecutorService with its own different channels) to be acknowledged, however the acks are not picked up by the server. I have written a simple test where I acknowledge the message from a different channel in the same thread and in a different thread, on the same thread they work, on a different one they do not, and the same channel on different threads works as well.

Has anyone come across this before? I really don't want to have to keep a mapping of channels to ids.

Upvotes: 3

Views: 2202

Answers (1)

mwaisgold
mwaisgold

Reputation: 106

It's not recommended at all to ack a message in a different thread, you should avoid this behavior. Here it is what the doc says: http://www.rabbitmq.com/api-guide.html#channel-threads

Upvotes: 0

Related Questions