Search code examples
rabbitmqamqpnode-amqp

Rabbitmq: different between envelop.message.body and envelop.message.pool


I have one producer based on nodejs and the javascript library which I used is amqp.node, and the consumer is implemented by C library.

From rabbitmq management web, I can see the messages are pushed into the queue and delivered to the consumer. In the consumer, the amqp_consume_message return AMQP-RESPONSE-NORMAL, however, the envelop.message.body is null. How can I debug it in this case?

Here are my codes to consume messages from rabbitmq

amqp_rpc_reply_t reply;
amqp_envelope_t envelope;
amqp_maybe_release_buffers(m_con); 
timeval m_time;
m_time.tv_sec = dwMilliseconds/1000;
m_time.tv_usec = (dwMilliseconds%1000)*1000;
reply = amqp_consume_message(m_con, &envelope, &m_time, 0);//time out 1 second
if (AMQP_RESPONSE_NORMAL != reply.reply_type)
{
    return false;
}

bool bRet = false;
amqp_bytes_t& rTheBody = envelope.message.body;
if (rTheBody.len > 0)
{

Update

After further investigation, I find those messages are stored in the envelop.message.pool.pages. I want to the different between message.body and message.pool?


Solution

  • Quoting this

    The pool field of the amqp_message_t object (e.g., envelope.message.pool) is a memory pool used for allocating parts of the message. It is an implementation detail and should not be used by client code directly (this implementation detail is subject to change).

    The only reason that the envelope.message.body.bytes should be NULL with a AMQP_RESPONSE_NORMAL return value is if a 0-length message body is received.