[rabbitmq-discuss] When I switch my network connection from one wifi router to another, two consumers are created

L H, Wong lhwong at gmail.com
Sat Nov 2 05:47:36 GMT 2013


On Thu, Oct 31, 2013 at 5:36 PM, Emile Joubert <emile at rabbitmq.com> wrote:

>
> Hi,
>
> On 31/10/13 07:46, Liong Hung Wong wrote:
>
> > When I switch my network connection from one wifi router to another, two
> > consumers are created for the queue as below. In that case, messages
> > will be distributed between both consumers, hence, the app only receives
> > alternate message until the first connection timeout due to heartbeat
> > setting.
>
> If you want to ensure that only one consumer can get messages from a
> queue then set the exclusive flag.
>
>
If I set the queue exclusive flag, the new connection/channel can not be
attached to the queue until the first connection timeout. The queue is a
permanent queue so that the client doesn't miss any message published to
the queue when the client is offline.



> > I am not able to cancel the first consumer with
> > channel.basicCancel(consumerTag) when as the connection has already been
> > closed. Is there any way to overcome this problem?
>
> This should not be a problem. If the connection of one consumer has
> already closed by the time the second consumer opened then there will be
> no overlap in subscriptions. If consumers subscribe without autoAck then
> unacknowledged messages will be returned to the queue when a connection
> terminates, and any subsequent consumer will be able to process such
> messages.
>
>
> The first connection has not been closed on the server although it has
been closed on the client side (the close command doesn't get sent to the
server as the network connection is already down). The first connection on
the server only gets closed after heartbeat timeout (default 600s).

During the 600s, M1, M2, M3 and M4 published to the queue. New connection
only get M2, and M4 during the 600s. After the first connection closed, the
new connection/channel gets M1 and M3. What I want to achieve is to be able
to get all of the messages in real-time.




>
> -Emile
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131102/fb35a735/attachment.htm>


More information about the rabbitmq-discuss mailing list