Setting the Connection URL

This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Setting the Connection URL

When a JMS client connects to WSO2 Message Broker (WSO2 MB), the connection parameters are specified using the connectionfactory interface as shown below.

  • connectionfactory.ConnectionFactory = <Connection_URL>

  • connectionfactory.QueueConnectionFactory = <Connection_URL>

  • connectionfactory.TopicConnectionFactory = <Connection_URL>

See the following topics:

Parameters used in the connection URL

The connection URL takes the following format, when the AMQP transport is used:

amqp://[<user>:<pass>@][<clientid>][/<virtualhost>][?<option>='<value>'[&<option>='<value>']]


For example:

connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://IP1:5672'

Note that the clientID is used for identifying the client and is only applicable for durable topic subscriptions. However, since this value is not validated in WSO2 MB, you can enter any arbitrary string as the clientID.

Now, let's look at the parameters used in the above URL format:

  • <user>:<pass>@: This is the username:password that will be used to connect to WSO2 MB. Note that this user should have the required permissions granted in WSO2 MB. See the section for user permissions in WSO2 MB for more information on how permissions are defined.

  • /<virtualhost>: The name of the virtual host, where the virtual host is a path that acts as a namespace. A name consists of any combination of the following: At least one alphanumerical value [A-Za-z0-9] and optionally special characters [.-_+!=:].

  • <option>='<value>': You can enter multiple options with values as explained below. These options should be separated by '&'.

Using the 'brokerlist' option

When you use the brokerlist option, the broker URL should be as follows:

<transport>://<host>[:<port>][?<option>='<value>'[&<option>='<value>']]

Now, let's look at each of the parameters used in the broker URL:

  • <transport>: The transport should be TCP.

  • <host>: The IP address.

  • <port>: The default AMQP port of 5672 is used if no port is specified.

  • <option>='<value>': Each broker can have additional options that are specific to that broker. The following are the options that are currently implemented:

Using the 'failover' option

When you use the failover option, the following format should be followed:

failover='<method>[?<options>]'

Now, let's look at the parameters in the above format:

  • <method>: Listed below are the supported methods. Note that 'singlebroker' is used when only one broker is present and the 'roundrobin' method is used with multiple brokers. The 'nofailover' method is useful if you are using a 3rd party tool that has its own reconnection strategy that you wish to use.

  • <option>: The following options should be used for the failover method.

Example

For example, see how multiple brokers are defined in the connection URL, along with failover parameters.

connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?failover='roundrobin'&cyclecount='2'&brokerlist='tcp://localhost:5673?retries='5'&connectdelay='50';tcp://localhost:5674?retries='5'&connectdelay='50';tcp://localhost:5675?retries='5'&connectdelay='30000''