duplicate consumer after restart

411 views
Skip to first unread message

Mar

unread,
Mar 6, 2017, 10:08:32 AM3/6/17
to rabbitmq-users
Hello, 

I'd like to know how to reconnect automatically a consumer after a restart of rabbitMq service.( recovering) 

If I set automaticRecoveryEnabled=false in my connectionFactory in my program, any consumer will be connected after restarting. OK

If I set automaticRecoveryEnabled=true, after restarting the old consumer appears as connected (same consumer tag) and a 
new consumer is created, when a message arrives the old consumer takes the message and the message remains unacked, and it is blocked!  

Did I forget anything in the configuration? 

RabbitMQ 3.6.1, Erlang R16B03-1

Thanks
Regards, 
Mar

Arnaud Cogoluègnes

unread,
Mar 7, 2017, 3:48:39 AM3/7/17
to rabbitm...@googlegroups.com
Automatic recovery kicks in when the client loses the connection to the server. Any un-acked message becomes available again for consumption.

What do you mean by "restarting"? Do you restart the client process? If so, it's not necessary when automatic recovery is on.

Please provide more information (e.g. the client you're using), code samples, and a more detailed description of what you're exactly doing/trying to test. We can't really help with so little information.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mar

unread,
Mar 7, 2017, 12:32:48 PM3/7/17
to rabbitmq-users
I have a java client with a Java consumer (using Rabbit client AMQP library).  It is inside a OSGI container.

The consumer is a 
BlockingQueueConsumer(cachingConnectionFactory, new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(), AcknowledgeMode.MANUAL, false, 500, true, new HashMap<String, Object>(), false, "queueName");

and the connectionFactory has automaticRecoveryEnabled=true

In the http API (management plugin)  I can see (Queue details) my consumer connected:

ChannelConsumer tagAck requiredExclusivePrefetch countArguments
127.0.0.1:46807 (13)amq.ctag-G5zjUfxh7Xj-eVy67lUBfw500



After doing service rabbitmq-server restart, the consumer tag is the same and if I send messages, all messages remain unacked

 
Ready
0
Unacked
5
Total
5





When I use a BlockingQueueConsumer I don't have the problem of consumer duplication.

Thanks
Regards, 
Mar

On Tuesday, March 7, 2017 at 9:48:39 AM UTC+1, Arnaud Cogoluègnes wrote:
Automatic recovery kicks in when the client loses the connection to the server. Any un-acked message becomes available again for consumption.

What do you mean by "restarting"? Do you restart the client process? If so, it's not necessary when automatic recovery is on.

Please provide more information (e.g. the client you're using), code samples, and a more detailed description of what you're exactly doing/trying to test. We can't really help with so little information.
On Mon, Mar 6, 2017 at 4:08 PM, Mar <mar....@gmail.com> wrote:
Hello, 

I'd like to know how to reconnect automatically a consumer after a restart of rabbitMq service.( recovering) 

If I set automaticRecoveryEnabled=false in my connectionFactory in my program, any consumer will be connected after restarting. OK

If I set automaticRecoveryEnabled=true, after restarting the old consumer appears as connected (same consumer tag) and a 
new consumer is created, when a message arrives the old consumer takes the message and the message remains unacked, and it is blocked!  

Did I forget anything in the configuration? 

RabbitMQ 3.6.1, Erlang R16B03-1

Thanks
Regards, 
Mar

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

Michael Klishin

unread,
Mar 7, 2017, 2:00:44 PM3/7/17
to rabbitm...@googlegroups.com
I don't know what "BlockingQueueConsumer" is (possibly something from Spring AMQP,
since RabbitMQ Java client doesn't have caching connection factories) but if it has anything to do
with the QueueingConsumer, that does not support automatic connection recovery.

So one new consumer is the recovered one, the original could be your own code recovering or something else.

See server logs to see inbound connections. Java client 4.x has a decent amount of logging you can enable.

Tools such as VisualVM and netstat can help narrow down connection objects, their sockets, and what state they are in.

Gary Russell

unread,
Mar 7, 2017, 2:54:15 PM3/7/17
to rabbitm...@googlegroups.com
You don't need autoRecoveryEnabled with Spring AMQP; it has had its own connection recovery that predates the client autorecovery.

That said, Spring AMQP (since 1.4) can co-exist with autoRecovery and should not leave consumers lingering like that.

If you are using a version 1.4 or later, please describe how to reproduce.

If you are using an earlier version, you need to turn it off, or upgrade.


To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages