[rabbitmq-discuss] Send message and wait for ACK for X seconds
Ceri Storey
ceri at lshift.net
Tue Sep 17 12:01:52 BST 2013
(17/09/13 11:09), Matthieu Napoli wrote:
> I have a basic work queue, and some work tasks are very fast. I can't
> predict whether a task will take 0.1s or 10min.
>
> What I'd like to do is have the producer (HTTP web request) send a job
> to a worker, and wait for 3 seconds. If the job is done by then, then
> I can display "OK" to the user, else I stop waiting and I display "It
> will be effective soon".
>
> A way to do this is using a RPC-style, bidirectional communication.
> That's unnecessarily complex because I don't need the result of the job.
>
> Another way would be to simply wait for the ACK of the worker (task
> completed).
>
> So my question: is there a way to wait for the ACK of a message (i.e.
> consumer finished processing it) on the producer side?
I'm afraid not--the Acks are just used by the broker itself, and they're
not exposed to clients. The nearest you could get is by polling the
numbers of acknowledged / unacknowledged messages in a given queue, but
that would (at best) be an approximation.
If you don't want to send replies via RabbitMQ, then it might suffice to
use a side channel--eg: set a flag in Redis or other database. That
said, unless you otherwise need that information (eg: recording the that
something about an entity has changed) it'd likely just add more
complexity than sending the reply via Rabbit.
Hope that helps,
More information about the rabbitmq-discuss
mailing list