Menu Search

14.10. Queue Binding

A queue can be bound to an exchange in virtual host configuration file by providing an exchange name in element exchange within the queue configuration element having the same name as a queue. If exchange element is omitted in queue configuration then such queue is bound to a default exchange only. With configuration file it is only possible to bind queue to a single exchange.

An element routingKey is used to specify a custom binding key. It is an optional element, and, if it is not set then queue is bound to an exchange with a binding key equals to a queue name. Any number of binding keys can be configured.

Binding arguments can be set with each binding key. An element bindingArgument is used to specify a binding argument as a name-value pair separated with equal character. Any number of binding arguments can be provided for a binding key in their own bindingArgument elements. All of them should be contained within an element having the same name as a binding key.

The following example demonstrates how to bind queue testQueue to a default topic exchange using routing key testRoutingKey and binding arguments for message selector and no local.

Example 14.14. Queue Binding Example