[rabbitmq-discuss] dead connection ?

Marek Majkowski majek04 at gmail.com
Wed Sep 14 16:30:45 BST 2011


On Wed, Sep 14, 2011 at 09:57, ludy <ludy at wawame.cn> wrote:
> i want to use rabbitmq for android push.i use device id to name a
> queue.when mobile switches network,mobile will reconnect to the
> queue,and then the queue do not send message to the new consumer
> immediately.the old consumer is still exist but connection is not
> alive,how can i set a queue only receive one alive consumer???

Ludy,

There are few things you can do.

First, if you used 'basic.qos' with 'prefetch-count=1', that would
mean only one message will be delivered to the inactive connection
(and thus, potentially lost). But remember this may slow down
message delivery to your clients.

Next, the connection is probably just stalled and it will properly
closed when TCP detects that. It can take a while. You can speed
up this process by using keepalives (either on AMQP layer or
on tcp layer). Messages that were delivered to 'dead' connection
will get redelivered, and you will lose no data. (messages
could be delivered not in order).

At last, you could change your architecture so that every connection
creates a new, temporary (exclusive) queue. This kind of setup
would mean that for all messages in a queue will be delivered
to only one connection - thus reducing complexity of dead connections.
But that would probably require support from your application -
you would probably need to do some kind of replay when client
connects.

Cheers,
  Marek


More information about the rabbitmq-discuss mailing list