Info |
---|
This page is out of date and should not be used. Please refer to the Qpid JMS client books for up to date documentation. |
Format
No Format |
---|
amqp://[<user>:<pass>@][<clientid>]<virtualhost>[?<option>='<value>'[&<option>='<value>']]
|
The connection url defines the values that are common across the cluster of brokers. The virtual host is second in the list as the AMQP specification demands that it start with a '/' otherwise it be more readable to be swapped with clientid. There is currently only one required option and that is the brokerlist option. In addition the following options are recognised.
Worked Example
You could use a URL which looks something like this:
amqp://guest:guest@client1/development?brokerlist='tcp://localhost:5672'
Breaking this example down, here's what it all means:
amqp = the protocol we're using
guest:guest@localhost = username:password@clientid where the clientid is the name of your server (used under the covers but don't worry about this for now). Always use the guest:guest combination at the moment.
development = the name of the virtualhost, where the virtualhost is a path which acts as a namespace. You can effectively use any value here so long as you're consistent throughout. The virtualhost must start with a slash "/" and continue with names separated by slashes. A name consists of any combination of at least one of [A-Za-z0-9] plus zero or more of [.-_+!=:].
brokerlist = this is the host address and port for the broker you want to connect to. The connection factory will assume tcp if you don't specify a transport protocol. The port also defaults to 5672. Naturally you have to put at least one broker in this list.
This example is not using failover so only provides one host for the broker. If you do wish to connect using failover you can provide two (or more) brokers in the format:
brokerlist='tcp://host1&tcp://host2:5673'
The default failover setup will automatically retry each broker once after a failed connection. If the brokerlist contains more than one server then these servers are tried in a round robin. Details on how to modifiy this behaviour will follow soon !
Options
Option | Default | Description |
---|---|---|
Option | Default | Description |
ssl | false | Set the default for all connections. This can be overridden by the individual broker url.|
brokerlist | see below | The list of brokers to use for this connection |
failover | see below | The type of failover method to use with the broker list. |
cyclecountmaxprefetch | 05000 | The maximum number of times messages to loop through the list of available brokers before failureprefetch from the broker. |
Brokerlist option
No Format |
---|
brokerlist='<broker url>[;<broker url>]'
|
...
Broker URL format
No Format |
---|
<transport>://<host>[:<port>][?<option>='<value>'[&<option>='<value>']]
|
...
Option | Default | Description |
---|---|---|
retries | 1 | The number of times to retry connection to this Broker |
ssl | false | Use ssl on the connection |
connecttimeout | 30000 | How long in (milliseconds) to wait for the connection to succeed |
connectdelay | none | How long in (milliseconds) to wait before attempting to reconnect |
Brokerlist failover option
No Format |
---|
failover='<method>[?<options>]'
|
...
Method | Description |
---|---|
singlebroker | This will only use the first broker in the list. |
roundrobin | This method tries each broker in turn. |
nofailover | [New in 0.5] This method disables all retry and failover logic. |
The current defaults are naturally to use the 'singlebroker' when only one broker is present and the 'roundrobin' method with multiple brokers. The '''method''' value in the URL may also be any valid class on the classpath that implements the FailoverMethod
interface.
The 'nofailover' method is useful if you are using a 3rd party tool such as Mule that has its own reconnection strategy that you wish to use.
Options
Option | Default | Description |
---|---|---|
cyclecount | 1 | The number of times to loop through the list of available brokers before failure. |
Note: Default was changed from 0 to 1 in Release 0.5
Sample URLs
No Format |
---|
amqp:///test?brokerlist='localhost' amqp:///test?brokerlist='tcp://anotherhost:5684?retries='10'' amqp://guest:guest@/test?brokerlist='vm://:1;vm://:2'&failover='roundrobin' amqp://guest:guest@/test?brokerlist='vm://:1;vm://:2'&failover='roundrobin?cyclecount='20'' amqp://guest:guest@client/test?ssl='true'&brokerlist='tcp://localhost;tcp://redundant-server:5673?ssl='falsetrue''&failover='roundrobin' amqp://guest:guest@/test?brokerlist='vm://:1'&failover='nofailover' |