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}")
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.