[rabbitmq-discuss] Headers exchange with rabbitmq-c?

Attila Nagy bra at fsn.hu
Mon Sep 24 13:31:56 BST 2012


Wow, this mailing list is wonderful, somehow it planted the solution 
into my mind. :)

Here is the example -I missed the AMQP_BASIC_HEADERS_FLAG.

     amqp_table_entry_t entries[1];
     amqp_table_t table;

     entries[0].key = amqp_cstring_bytes("test");
     entries[0].value.kind = AMQP_FIELD_KIND_UTF8;
     entries[0].value.value.bytes = amqp_cstring_bytes("test");

     table.num_entries = 1;
     table.entries = entries;
     qsort(table.entries, table.num_entries, sizeof(amqp_table_entry_t), 
&amqp_table_entry_cmp);

     amqp_basic_properties_t props;
     props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | 
AMQP_BASIC_DELIVERY_MODE_FLAG | AMQP_BASIC_HEADERS_FLAG;
     props.content_type = amqp_cstring_bytes("text/plain");
     props.delivery_mode = 2; /* persistent delivery mode */
     props.headers = table;
     amqp_basic_publish(
             self->conn,
             1,
             amqp_cstring_bytes("test"),
             amqp_cstring_bytes(""),
             0,
             0,
             &props,
             amqp_cstring_bytes("test"));

On 09/24/12 14:22, Attila Nagy wrote:
> So far I have tried this, without success:
>
>     amqp_table_entry_t entries[1];
>     amqp_table_t table;
>
>     entries[0].key = amqp_cstring_bytes("test");
>     entries[0].value.kind = AMQP_FIELD_KIND_UTF8;
>     entries[0].value.value.bytes = amqp_cstring_bytes("test");
>
>     table.num_entries = 1;
>     table.entries = entries;
>     qsort(table.entries, table.num_entries, 
> sizeof(amqp_table_entry_t), &amqp_table_entry_cmp);
>
>     amqp_basic_properties_t props;
>     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 */
>     props.headers = table;
>     amqp_basic_publish(
>             self->conn,
>             1,
>             amqp_cstring_bytes("test"),
>             amqp_cstring_bytes(""),
>             0,
>             0,
>             &props,
>             amqp_cstring_bytes("test"));
>
> On 09/24/12 13:30, Attila Nagy wrote:
>> Hi,
>>
>> I would like to use headers exchange with rabbitmq-c, but I couldn't 
>> yet find out how could I specify custom headers for a message.
>> Could somebody help me out (and the others who asked this on the net) 
>> with an example?
>>
>> Thanks,
>



More information about the rabbitmq-discuss mailing list