Table of Contents
The Binding URL syntax for addressing[5]. It allows the specification of the bindings between a queue and an exchange, queue and exchange creation arguments and some ancillary options.
The format for a Binding URL is provided below
<Exchange Class>://<Exchange Name>/[<Destination>]/[<Queue>][?<option>='<value>'[&<option>='<value>']]
where
Exchange Class, specifies the type of the exchange, for example, direct,topic,fanout, etc.
Exchange Name, specifies the name of the exchange, for example, amq.direct,amq.topic, etc.
Destination, is an optional part of Binding URL. It can be used to specify a routing key with the non direct exchanges if an option routingkey is not specified. If both Destination and option routingkey are specified, then option routingkey has precedence.
Queue, is an optional part of Binding URL to specify a queue name for JMS queue destination. It is ignored in JMS topic destinations. Queue names may consist of any mixture of digits, letters, and underscores
Options, key-value pairs separated by '=' character specifying queue and exchange creation arguments, routing key, client behaviour, etc.
Take care with the quoting surrounding option values. Each option value must be surrounded with single quotes (').
The following Binding URL options are currently defined:
Table 8.1. Binding URL options
The Qpid client Binding URLs for JMS queue destinations can be declared using direct exchange (Mostly it is a pre-defined exchange with a name "amq.direct". Also, custom direct exchanges can be used.):
direct://amq.direct//<Queue Name>
The Binding URLs for destinations created with calls to Session.createQueue(String) can be expressed as
direct://amq.direct//<Queue Name>?durable='true'
The durability flag is set to true in such destinations.
Example 8.1. Binding URL examples for JMS queues
direct://amq.direct//myNonDurableQueue direct://amq.direct//myDurableQueue?durable='true' direct://amq.direct//myAnotherQueue?durable='true'&routingkey='myqueue' direct://amq.direct//myQueue?durable='true'&routingkey='myqueue'&rejectbehaviour='server' direct://custom.direct//yetAnotherQueue
The Binding URLs for JMS queue destinations can be declared using topic exchange (A pre-defined exchange having name "amq.topic" is used mainly. However, custom topic exchanges can be used as well):
topic://amq.topic//<Queue name>?routingkey='<Topic Name>'&exclusive='true'&autodelete='true'
The Binding URLs for a topic destination created with calls to Session.createTopic("hello") is provided below:
Example 8.2. Binding URL examples for JMS topics
topic://amq.topic/hello/tmp_127_0_0_1_36973_1?routingkey='hello'&exclusive='true'&autodelete='true'
AMQP exchanges of class topic can route messages to the queues using special matches containing wildcard characters (a "#" matches one or more words, a "*" matches a single word). The routing keys words are separated with a "." delimiter to distinguish words for matching. Thus, if a consumer application specifies a routing key in the destination like "usa.#", it should receive all the messages matching to that routing key. For example, "usa.boston", "usa.new-york", etc.
The examples of the Binding URLs having routing keys with wildcards characters are provided below:
topic://amq.topic?routingkey='stocks.#' topic://amq.topic?routingkey='stocks.*.ibm' topic://amq.topic?routingkey='stocks.nyse.ibm'
Table 8.2. Binding URL examples
Binding URL | Description |
---|---|
fanout://amq.fanout//myQueue | Binding URL binding queue "myQueue" to predefined "amq.fanout" exchange of class "fanout" |
topic://custom.topic//anotherQueue?routingkey='aq' | Binding URL binding queue "anotherQueue" to the exchange with name "custom.topic" of class "topic" using binding key "aq". |
[5] The client also supports the Address/ADDR format. This is documented in Using the Qpid AMQP 0-10 JMS Client.
Apache Qpid, Messaging built on AMQP; Copyright © 2015 The Apache Software Foundation; Licensed under the Apache License, Version 2.0; Apache Qpid, Qpid, Qpid Proton, Proton, Apache, the Apache feather logo, and the Apache Qpid project logo are trademarks of The Apache Software Foundation; All other marks mentioned may be trademarks or registered trademarks of their respective owners