[rabbitmq-discuss] Rabbitmq-C amqp_basic_publish crash on connection loss

Lothe Shashank Shashank.Lothe at techmahindra.com
Wed Oct 9 13:56:59 BST 2013


Hi Alan,

Thanks for your earlier prompt replies. I am simulating a situation to test amqp_basic_publish. I modified the amqp_sendstring example to publish a message to the broker every 3 seconds. While the messages are getting published, I stop the broker using "rabbitmqctl stop_app". As the broker is stopped, amqp_basic_publish is crashed.

Code snippet as follows.

while(1)
{
    amqp_basic_properties_t props;
    struct timeval t;
    int ret;

    t.tv_sec = 3;
    t.tv_usec = 0;
    select(0, NULL, NULL, NULL, &t);

    props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG;
    props.content_type = amqp_cstring_bytes("text/plain");
    props.delivery_mode = 2; /* persistent delivery mode */
    printf("conn %u\n",conn);
    ret=amqp_basic_publish(conn,
                            1,
                            amqp_cstring_bytes(exchange),
                            amqp_cstring_bytes(routingkey),
                            1,
                            0,
                            &props,
                            amqp_cstring_bytes(messagebody));
    printf("ret=%d\n",ret);
}

Program output:
conn 143663112
ret=0
conn 143663112
ret=0
conn 143663112

First 2 published happened properly. After that I stopped broker. The program terminated. Considering this scenario, I would like to understand
1. if there is a way to check the connection before I publish
2. if the connection value becomes NULL, as we stop the broker.

Thanks and regards,
Shashank

________________________________

DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131009/5e24cc19/attachment.htm>


More information about the rabbitmq-discuss mailing list