jlouis / turtle

A wrapper on the RabbitMQ Erlang Client (Erlang)
Other
71 stars 15 forks source link

Provide support like rpc_await for publish to allow for caller to check for confirms #4

Open sdebnath opened 8 years ago

sdebnath commented 8 years ago

Creating an issue as a discussion placeholder for implementing support similar to rpc_await for publish. This will allow client scenarios such as

1) begin transaction with some db 2) publish a message to RabbitMQ to do some heavy work somewhere else (call it publish_async?) 3) do some local work 4) check with turtle via publish_await to see if rabbitmq confirmed receipt 5) if confirmed, commit tx, else rollback 6) party.

jlouis commented 8 years ago

First a caveat for the reader: under network partitions, I would not trust RabbitMQ to provide delivery guarantees. The situation is murky and the guarantees provided are not entirely clear to me. That said, however...

I think an async publication makes a lot of sense. Currently, we block the caller until publication goes through and then we unblock the caller. In the proposed solution, you can do other things "in between". One way to go at it, is to generalize the reply_to_caller path in the publisher: