[rabbitmq-discuss] rabbitmq-c: how to catch a broken pipe with the rabbitmq server

underattack7 underattack7 at googlemail.com
Thu Feb 10 15:21:30 GMT 2011


Hi,

I am using the rabbitmq-c C libraries to publish messages to a Rabbitmq
exchange.

Problem I have is that when rabbitmq server stops for some reason
(rabbtmqctl stop_app / start_app for instance), the socket between my
publisher program and rabbitmq is destroyed but I don't manage to catch any
error code properly so that the program can try to establish a new
connection.

When I stop rabbitmq, my publisher program exits with the message: "Broken
Pipe" when it tries to send a message.

Is there a way to check the socket before sending a message so that I can
try to re-establish a connection ?

The way I publish is :

rc = amqp_basic_publish(amqp_connection, 1,  amqp_cstring_bytes("Exchange"),
amqp_cstring_bytes(routingkey), 0, 0, NULL, body);

if (rc < 0)  {
    printf("error during publish : %s\n", strerror(-rc)) ;
 }

problem is that if rabbitmq is stopped,  the line "rc = amqp_basic_publish
...make the program exit, I cannot get the rc value).

Thanks,
Regards,

Fab
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110210/1cfe8c6f/attachment.htm>


More information about the rabbitmq-discuss mailing list