## Discovery Agents

### Overview

A discovery agent is a bootstrap mechanism that enables a client or message broker to discover other broker instances on a network. On the client side, the purpose of the discovery agent is simply to obtain a list of broker URIs. The list of URIs is then processed by the dynamic discovery protocol, `discovery://(...)`, which opens a connection to one of the URIs in the list.

Discovery agents typically use some form of ping mechanism to discover the broker URIs. Hence, it is usually necessary to enable the discovery mechanism on the server side as well (an exception to this requirement is the `simple` discovery agent).

### Configuring discovery agents on the message broker

For certain kinds of discovery agent (for example, multicast or rendezvous), it is necessary to enable the discovery agent in the message broker configuration. For example, to enable the multicast discovery agent on an Openwire endpoint, you should edit the relevant `transportConnector` element as follows:

        <transportConnectors>
            <transportConnector
                name="openwire" uri="tcp://localhost:61716" discoveryUri="multicast://default"/>
        </transportConnectors>

Where the `discoveryUri` attribute on the `transportConnector` element is initialized to `multicast://default`. You can associate multiple endpoints with the same discovery agent. For example, to configure both an Openwire endpoint and a Stomp endpoint to use the `multicast://default` discovery agent:

        <transportConnectors>
            <transportConnector
                name="openwire" uri="tcp://localhost:61716" discoveryUri="multicast://default"/>
            <transportConnector
                name="stomp" uri="stomp://localhost:61613"  discoveryUri="multicast://default"/>
        </transportConnectors>

### Using a discovery agent on the client side

You cannot use a discovery agent URI directly, on the client side. A discovery agent is not a transport protocol and it is not recognized as such by messaging clients. To use a discovery agent on the client side, the agent URI,`DiscoveryAgentUri`, is embedded inside a discovery URL, as follows:

    discovery://(DiscoveryAgentUri)?TransportOptions

The client recognizes the discovery URL as a transport. It first obtains a list of available endpoint URLs using the specified discovery agent and then connects to one of the discovered URLs. For more details about the discovery protocol, see Dynamic Discovery Protocol .

### Configuring broker networks

### Discovery agents

FUSE Message Broker currently supports the following discovery agents:

- Simple (static) discovery agent .

- Multicast discovery agent .

- Rendezvous discovery agent .

### Simple (static) discovery agent

The simple (static) discovery agent provides an explicit list of broker URLs for a client to connect to. For example:

    simple://(tcp://localhost:61716,tcp://localhost:61816)

In general, the URI for a simple discovery agent must conform to the following syntax:

    simple://(URI1,URI2,URI3,...)

Or equivalently:

    static://(URI1,URI2,URI3,...)

The two prefixes, `simple:` and `static:`, are exactly equivalent. In order to use the agent URI, it must be embedded inside a discovery URL—for example:

    discovery://(static://(tcp://localhost:61716,tcp://localhost:61816))

This discovery agent is only used on the client side. No extra configuration is required in the broker.

### Multicast discovery agent

The multicast discovery agent uses the IP multicast protocol to find any message brokers currently active on the local network. In order for the protocol to work, a multicast discovery agent must be enabled on each broker you want to advertise and messaging clients must be configured to use a `discovery` URI.

The URI for a multicast discovery agent must conform to the following syntax:

    multicast://GroupID

Where the `GroupID` is an alphanumeric identifier. All participants in the same discovery network must use the same `GroupID`. For example, the FUSE Message Broker is usually configured to use the URI, `multicast://default`.

### Rendezvous discovery agent

The rendezvous discovery agent is derived from Apple’s Bonjour Networking technology, which defines the rendezvous protocol as a mechanism for discovering services on a network. To enable the protocol, a multicast discovery agent must be configured on each broker you want to advertise and messaging clients must be configured to use a `discovery` URI.

The URI for a rendezvous discovery agent must conform to the following syntax:

    rendezvous://GroupID

Where the `GroupID` is an alphanumeric identifier. All participants in the same discovery network must use the same `GroupID`.

For example, to use a rendezvous discovery agent on the client side, where the client needs to connect to the `groupA` group, you would construct a discovery URL like the following:

    discovery://(rendezvous://groupA)