<div>Hi,</div><div><br></div><div>I've developed an application that consumes messages from a queue ("events queue") and depending on their data</div><div>it publishes (per received message) a message to another queue ("results queue")</div>
<div><br></div><div>The logic that checks the content of the received messages is publishing messages using BasicPublish (with mandatory=2, immediate=false and setting</div><div>deliveryMode=2 to the messages to be sent)</div>
<div>My concern is that BasicPublish is asynchronous and the only exception I can get is when there is no connection to RabbitMQ or the destination exchange does not exist.</div><div><br></div><div>Since the application logic at this point is synchronous I can't use BasicReturn in order to use a handler when messages can't be delivered.</div>
<div><br></div><div>I've been googling a lot and some people suggested using this schema: </div><div><br></div><div>ch.TxSelect()</div><div>ch.BasicPublish(.....)</div><div>ch.TxCommit()</div><div><br></div><div>and also is suggested that "commit-ok" will be returned if the message has been published safely to the broker.</div>
<div><br></div><div>Reading the API user guide I've found that this is called "transfer responsibility".</div><div><br></div><div>Copy & paste follows:</div><div><br></div><div>--</div><div>To transfer responsibility for delivery of a message to a broker</div>
<div> ensure (ahead of time) that the target queue exists and is durable,</div><div> select Tx mode using IModel.TxSelect,</div><div> publish the message with the "mandatory" flag set and DeliveryMode set equal to 2, and</div>
<div> commit the Tx transaction using IModel.TxCommit.</div><div><br></div><div>Once a broker replies with CommitOk (i.e. the TxCommit() call returns to the caller), it has taken</div><div>responsibility for keeping the message on disk and on the target queue until some other application</div>
<div>retrieves and acknowledges the message.</div><div>A commit is not required after every message: batching of publications may be done, depending on the</div><div>precise delivery guarantees the publishing application requires.</div>
<div>Responsibility can also be placed with an external database, even further along the chain - see the section</div><div>on interaction with external resources below</div><div>---</div><div><br></div><div>My question is: </div>
<div><br></div><div>Being TxCommit a void function I tested this block of code using a non-existing routing key and I didn't get any exception.</div><div>Since safe publishing would be highly desiderable non routed messages should be detected because the application ACKs the messages of "events queue"</div>
<div>when after evaluating its content has successfully sent another message to the "results queue" (currently if a a routing key is not being routed to a queue the messages are silently dropped and I have no way to detect the failure so the application ACKs the messages from "events queue")</div>
<div><br></div><div>Please, can someone tell me how I can't get that "CommitOK" responses?</div><div><br></div><div><br></div><div>Thank you in advance.</div><div><br></div><div><br></div><div>Alfonso</div><div>
<br></div><div>PS: I'm using the API version 1.7.2 and RabbitMQ server is the same version.</div><div><br></div><div><br></div><div><br></div>