Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why there is a duplicated consumer after a connection recovery in RabbitMQ?

I am using:

  • RabbitMQ 3.5.1
  • Java RabbitMQ client
  • Cluster with two RabbitMQ instances

I have a queue that is:

  • Durable=false
  • Exclusive=false
  • Auto-delete=true
  • Queue mirroring didn't affect the results

In my application there is an asynchronous consumer receiving the messages through a callback. The problem happens when I try to simulate a connection failure by disabling the network communication with the broker. After the connection is restablished the queue (in the web administration interface) is showing two consumers connected with the same consumer tag, but with different port numbers.

When I stop the app one of the consumers disappears, but the other one remains connected, thus the queue is not deleted. Is this expected or I do I have to change something to avoid this?

like image 886
Toresan Avatar asked Nov 01 '22 00:11

Toresan


1 Answers

There were two connections because the default heartbeat is 580 seconds, so it would take that time to the server detects it.

When that value was set to a lower value the first connection was closed right away. More details about the heartbeat option in Detecting Dead TCP Connections with Heartbeats

Thanks Gas for the tip of using the RabbitMQ user group forum.

like image 161
Toresan Avatar answered Nov 02 '22 14:11

Toresan