The dynamic discovery protocol combines reconnect logic with the capability to auto-discover broker endpoints in the local network. The discovery protocol invokes a discovery agent in order to build up a list of broker URIs. The protocol then randomly chooses a URI from the list and attempts to establish a connection to it. If it does not succeed, or if it subsequently fails, a new connection is established to one of the other URIs in the list.
A discovery agent is a bootstrap mechanism that enables a message broker, consumer, or producer to obtain a list of broker URIs, where the URIs represent connector endpoints. The broker, consumer, or producer can subsequently connect to one of the URIs in the list.
The following kinds of discovery agent are currently supported in Fuse Message Broker:
Simple (static) discovery agent.
Multicast discovery agent.
Zeroconf discovery agent.
For more details, see Discovery Agents.
Before you can use the discovery protocol, you must make your broker’s endpoints
discoverable by adding a discovery agent to each transport connector. For example,
to make a TCP transport connector discoverable, set the
discoveryUri
attribute on the
transportConnector
element as follows:
<transportConnectors> <transportConnector name="openwire" uri="tcp://localhost:61716" discoveryUri="multicast://default"/> </transportConnectors>
Where the TCP transport connector is configured to use the multicast discovery
agent, multicast://default
.
A discovery
URI must conform to the following syntax:
discovery://(DiscoveryAgentUri
)?TransportOptions
Where the discovery agent URI, DiscoveryAgentUri
,
identifies a discovery agent, as described in Discovery agents above. The transport options,
?
TransportOptions
, are specified
in the form of a query list (where the supported options are described in Table 7.1 ). If no transport options are
required, you can use the following alternative syntax:
discovery://DiscoveryAgentUri
The discovery protocol supports the transport options described in Table 7.1
Table 7.1. Discovery Transport Options
Option Name | Default | Description |
---|---|---|
initialReconnectDelay | 10 | How long to wait before the first reconnect attempt (in ms). |
maxReconnectDelay | 30000 | The maximum amount of time to wait between reconnect attempts (in ms). |
useExponentialBackOff | true | If true , use an exponential back-off between
reconnect attempts. |
backOffMultiplier | 2 | The exponent used in the exponential back-off algorithm. |
maxReconnectAttempts | 0 | If not 0 , this is the maximum number of
reconnect attempts before an error is sent back to the
client. |
The following is an example of a discovery URI that uses a multicast discovery agent:
discovery://(multicast://default)?initialReconnectDelay=100
The list of transport options, TransportOptions
, in the
discovery URI can also be used to set options on the discovered
transports. If you set an option not listed in Table 7.1, the URI parser attempts to inject the option setting into
every one of the discovered endpoints.
For example, if you set the TCP connectionTimeout
option to 10
seconds, as follows:
discovery://(multicast://default)?connectionTimeout=10000
The 10 second timeout setting is injected into every discovered TCP endpoint.