Aditya Ekbote
Aditya Ekbote

Reputation: 1553

Asynchronous ack in rabbitmq

First let me tell you set up i have.

  1. Durable and persistent queue and exchange.
  2. Manual ack.
  3. Using rabbitmq in spring boot.
  4. SimpleMessageListenerContainer having concurrent consumer as 10 and max consumer as 50.

The probelm scenario is, I am sending message m1 and then m2. m1 takes time to process. m2 process gets finished before m1. Here for both m1 & m2, delivery tags are same as 1. So message m2 is getting acked before m1 and when m1 is acked, i am getting unknown delivery tag 1 exception.

Surprisingly message m1 ack is received by producer too. But the problem is m1 hands in unacked state for a long time in RMQ admin console.

Is this possible in RMQ that i can ack m2 before m1? I know both messages are on same channel and same queue. The thing is i can not gurantee both message to get delivered to separate queues.

Upvotes: 0

Views: 1417

Answers (1)

Gary Russell
Gary Russell

Reputation: 174749

If they have the same delivery tag, they were delivered on different threads/channels - delivery tags are scoped at the channel level. It appears you are trying to ack m1 on the wrong channel.

Surprisingly message m1 ack is received by producer too.

I don't know what you mean by that - consumer acks don't go to producers; consumers and producers are independent. Producer acks are completely different to consumer acks.

You are advised not to send acks on a different thread; channels are not thread safe.

Upvotes: 1

Related Questions