alanxz / rabbitmq-c

RabbitMQ C client
MIT License
1.77k stars 671 forks source link

adding u32 value to message header causes queue die #522

Open williamlee1982 opened 6 years ago

williamlee1982 commented 6 years ago

found a strange behavior on the 0.9.0, queue die while sending a message which contains a u32 header. rabbit mq server version is 3.7.7, Erlang 21.0.1 on windows 7 64bit. here is the code snippet:

int send_reply(amqp_connection_state_t conn, amqp_bytes_t reply_to, amqp_bytes_t correlation_id,  amqp_bytes_t msg)
{
    amqp_basic_properties_t props;
    amqp_table_t* tables;
    amqp_table_entry_t entries[1];

    memset(&props, 0x00, sizeof(amqp_basic_properties_t));
    memset(&entries, 0x00, sizeof(amqp_table_entry_t));

    props._flags = AMQP_BASIC_CORRELATION_ID_FLAG | AMQP_BASIC_HEADERS_FLAG;
    props.correlation_id = correlation_id;

    tables = &(props.headers);
    props.headers.num_entries = 1;
    props.headers.entries = entries;
    entries[0].key = amqp_cstring_bytes(MSG_HAS_BINARY);
    entries[0].value.kind = AMQP_FIELD_KIND_U32;
    entries[0].value.value.u32 = 0;

    amqp_basic_publish(conn, 1, amqp_cstring_bytes(""), reply_to, 0, 0, &props, msg);

    return 0;
}

but if i changed to i32 like this, it will be ok.

    entries[0].value.kind = AMQP_FIELD_KIND_I32;
    entries[0].value.value.i32 = 0;

i have no idea what happen, would you please take a look? thank you so much. BTW, queue die means it's disappear on the RabbitMQ web UI.

alanxz commented 6 years ago

Are there any interesting log entries emitted by the broker when the queue goes away?

From the client side, does the channel or connection get closed after publishing the message (call amqp_simple_wait_frame after publishing the message, which will return any channel.close or connection.close methods that resulted from publishing the message).