I'm using pika's twisted protocol adapter. When I have have successfully handled the message I send an acknowledgement to RabbitMQ using this call:
channel.basic_ack(delivery_tag=delivery_tag)
The basic_ack call seems to be firing asynchronously but it's not returning a deferred so I can't add a callback or errback. I've now run into a small problem because I want to wait for a certain message from the queue, process it and shutdown the reactor i.e.
channel.basic_ack(delivery_tag=delivery_tag)
reactor.stop()
Of course the reactor shuts down before the message is sent. I'm working around this by delaying the shutdown
channel.basic_ack(delivery_tag=delivery_tag)
reactor.callLater(5, reactor.stop)
But it seems like a pretty "hacky" way of doing it. I'd prefer to be able to do something like:
d = channel.basic_ack(...)
d.addBoth(lambda x: reactor.shutdown())
Am I missing something obvious here? Is it really not possible to chain a callback onto the end of an ack call?
So it seems the only option is to wait and hope the acknowledgement was sent successfully