[rabbitmq-discuss] How to determine if my message was publish successfully

cw storm cwstorm at gmail.com
Wed Oct 30 13:58:32 GMT 2013


MK,

This is my try/catch block code.  When I publish, it will also but success
just as long the exchange name is correct.  Even if you provide and invalid
routing key, it'll be success.  It doesn't goto the catch block.

try
{

ConnectionFactory factory = new ConnectionFactory();
factory.setUri(strFactoryURI);
Connection conn = factory.newConnection();
Channel channel = conn.createChannel();

AMQP.BasicProperties.Builder ct = new AMQP.BasicProperties.Builder();
AMQP.BasicProperties contentTypeHeader =
ct.contentType(strContentType).build();

channel.basicPublish(strExchangeName, strRoutingKey, contentTypeHeader,
byteMessage);

SuccessPutFlag = "true";

channel.close();
conn.close();

} catch (Exception e) {
// do something
}
finally
{
pipelineCursor.insertAfter("SuccessPutFlag", SuccessPutFlag);
pipelineCursor.destroy();
}


On Tue, Oct 29, 2013 at 4:47 PM, Michael Klishin <mklishin at gopivotal.com>wrote:

> On 29 Oct 2013, at 22:49, cw storm <cwstorm at gmail.com> wrote:
>
> > However, I don't know how to capture the basic.return in my code to see
> if it was successful or not.  I was hoping it would goto the catch block
> but obviously it didn't.
>
> This depends on your client library. What client do you use? Can you post
> your test code?
>
> MK
>
> Software Engineer, Pivotal/RabbitMQ
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131030/26315728/attachment.htm>


More information about the rabbitmq-discuss mailing list