I am trying to create an exchange of type amq.fanout
using rabbitmq-c
, an amqp client for RabbitMQ . However, I'm getting tripped up on what exactly I have to declare for it. According to this, I have to declare the exchange name and type, and optionally durability and lifetime semantics for the exchange.
When I declare an exchange, it looks like I can supply the 'exchange', which I presume is the name of the exchange, and well as the exchange type, e.g. amq.fanout
. From examples/amqp_exchange_declare.c
amqp_exchange_declare(conn,
1,
amqp_cstring_bytes(exchange),
amqp_cstring_bytes(exchangetype),
0, 0, 0, 0,
amqp_empty_table);
But then if I look at an example of publishing, there is a place to supply the exchange type, in the second parameter which is named exchange
. For example, examples/amqp_producer.c
amqp_basic_publish(conn,
1,
amqp_cstring_bytes("amq.direct"),
amqp_cstring_bytes(queue_name),
0,
0,
NULL,
message_bytes)
But there's no place to supply the name of the exchange. So how can I publish to a named exchange?
And why the heck am I supplying a queue_name to publish? I should only be publishing to exchanges - queues are supposed to be hidden from the publisher. Is this all just poorly named variables in the examples or am I missing something fundamental?