4.6.2. Publish to a Queue using the Default Exchange
All queues automatically bind to the default exchange using the queue name as the binding key. So all you need to do to publish to a queue bound to the default exchange is to declare a queue. The binding to the Default Exchange is created automatically. Since the Default Exchange is a direct exchange, and is nameless, sending a message to the queue name is sufficient for it to arrive in your queue.
To create a queue named "quick-publish" bound to the Default Exchange using
qpid-config
:
qpid-config add queue quick-publish
In an application, queues can be created as a side-effect of creating a sender object. If the address contains the parameter
{create: always}
then the queue will be created if it does not already exist. In addition to always
, the create
command can also take the arguments sender
and receiver
, to indicate that the queue should be created only when a sender connects to the address, or only when a receiver connects to the address.
Here is the creation of the "quick-publish" example queue:
- Python
sender = session.sender("quick-publish; {create: always}")
- C++
Sender sender = session.createSender("quick-publish; {create: always}")