[rabbitmq-discuss] [RabbitMQ-c] Question about amqp_listen example

Roberto Pagliari roberto at canary.is
Fri Jan 17 00:51:35 GMT 2014


I have a couple of questions about the overall functioning of Rabbitmq-c.

>From amqp_listen.c I see the following code:

  {
    while (1) {
      amqp_rpc_reply_t res;
      amqp_envelope_t envelope;

      amqp_maybe_release_buffers(conn);

      res = amqp_consume_message(conn, &envelope, NULL, 0);

      if (AMQP_RESPONSE_NORMAL != res.reply_type) {
        break;
      }

      printf("Delivery %u, exchange %.*s routingkey %.*s\n",
             (unsigned) envelope.delivery_tag,
             (int) envelope.exchange.len, (char *) envelope.exchange.bytes,
             (int) envelope.routing_key.len, (char *)
envelope.routing_key.bytes);

      if (envelope.message.properties._flags & AMQP_BASIC_CONTENT_TYPE_FLAG) {
        printf("Content-type: %.*s\n",
               (int) envelope.message.properties.content_type.len,
               (char *) envelope.message.properties.content_type.bytes);
      }

      amqp_destroy_envelope(&envelope);
    }
  }


First off, the output I'm getting when sending the string "Hello world" is
$ ./amqp_listen localhost 5672 amq.direct test
Delivery 1, exchange amq.direct routingkey test
Content-type: text/plain


1) Is that what the output should be like? I though it was supposed to
print out the string sent with amqp_sendstring on the other side.
2) In the code above, it looks like the printf is performed every time,
regardless of weather a message has been received or not. However, only
when a message is actually received, the printf will execute. Could someone
explain me why this is the case?



Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140116/62a0b664/attachment.html>


More information about the rabbitmq-discuss mailing list