Wait for a single RabbitMQ message with a timeout?

I just added timeout support for amqplib in carrot.

I just added timeout support for amqplib in carrot. This is a subclass of amqplib. Client0_8.

Connection: github.com/ask/carrot/blob/master/carrot... wait_multi is a version of channel. Wait able to receive on an arbitrary number of channels. I guess this could be merged upstream at some point.

Now this is what I call a "great answer": "it's fixed"! Accepting - in the hope that it is merged into amqplib. – EMP May 10 '10 at 23:08.

This seems to break the whole idea of asynchronous processing, but if you must I think the right way to do it is to use an RpcClient.

While RpcClient itself is not useful to me, looking at its implementation reveals the approach to use: create a QueueingBasicConsumer and wait on its queue, which supports a timeout. This isn't as complex in . NET as I feared.

– EMP May 10 '10 at 0:57.

There's an example here using qpid with a msg = q. Get(timeout=1) that should do what you want. Sorry, I don't know what other AMQP client libraries implement timeouts (and in particular I don't know the two specific ones you mentioned).

Looking at the source of qpid it seems to use the exact same approach as the . NET client: basic_consume with a queue and waiting on the queue with a timeout. Looks like that's what I'll have to do.

– EMP May 10 '10 at 0:57.

Here's what I ended up doing in the . NET client: protected byte WaitForMessageWithTimeout(string queueName, int timeoutMs) { var consumer = new QueueingBasicConsumer(Channel); var tag = Channel. BasicConsume(queueName, true, null, consumer); try { object result; if (!consumer.Queue.

Dequeue(timeoutMs, out result)) throw new ApplicationException(string. Format("Timeout ({0} seconds) expired while waiting for an MQ response. ", timeoutMs / 1000.0)); return ((BasicDeliverEventArgs)result).

Body; } finally { Channel. BasicCancel(tag); } } Unfortunately, I cannot do the same with py-amqplib, because its basic_consume method does not call the callback unless you call channel.wait() and channel.wait() doesn't support timeouts! This silly limitation (which I keep running into) means that if you never receive another message your thread is frozen forever.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions