<div>Hi,</div><div><br></div><div>I&#39;ve developed an application that consumes messages from a queue (&quot;events queue&quot;) and depending on their data</div><div>it publishes (per received message) a message to another queue (&quot;results queue&quot;)</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&#39;t use BasicReturn in order to use a handler when messages can&#39;t be delivered.</div>
<div><br></div><div>I&#39;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 &quot;commit-ok&quot; will be returned if the message has been published safely to the broker.</div>
<div><br></div><div>Reading the API user guide I&#39;ve found that this is called &quot;transfer responsibility&quot;.</div><div><br></div><div>Copy &amp; 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 &quot;mandatory&quot; 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&#39;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 &quot;events queue&quot;</div>
<div>when after evaluating its content has successfully sent another message to the &quot;results queue&quot; (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 &quot;events queue&quot;)</div>
<div><br></div><div>Please, can someone tell me how I can&#39;t get that &quot;CommitOK&quot; 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&#39;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>