blob: e393f9f5db20c329b329cfaf1393eca28c187355 [file] [log] [blame]
<div class="wiki-content maincontent"><h2>Discovery Agents</h2><p>ActiveMQ uses an abstraction called a <a shape="rect" href="http://actievmq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/transport/discovery/DiscoveryAgent.html">Discovery Agent</a> to detect remote services such as remote brokers. We can use discovery for JMS clients to auto-detect a Message Broker to connect to, or to provide <link><page ri:content-title="Networks of Brokers"></page></link></p><p>There are currently two kinds of discovery agent.</p><h3>Multicast</h3><p>The Discovery transport uses our own Multicast based discovery agent to locate the list of URIs to connect to.</p><p>For more information see the <link><page ri:content-title="Discovery Transport Reference"></page></link>.</p><h3>Zeroconf</h3><p><link><page ri:content-title="ZeroConf"></page></link> is a standard discovery specification that uses UDP / multicast to discovery devices. Its used by Apple's Rendezvous services.<br clear="none"> We use the <a shape="rect" href="http://jmdns.sf.net/">jmDNS</a> project to implement the Zeroconf specification to detect services. This means other Zeroconf<br clear="none"> based tools can be used in conjunction with this discovery agent.</p><p>To configure discovery in a Broker you should use the <link><page ri:content-title="Xml Configuration"></page></link>. Here is an <a shape="rect" href="http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/receiver-zeroconf.xml?view=co">example</a> of using discovery to create <link><page ri:content-title="Networks of Brokers"></page></link>.</p><p>If you have one or more brokers running with Zeroconf discovery enabled you can connect to a broker using the brokerURL</p><structured-macro ac:macro-id="f1747328-7dfc-4d75-beaa-110c0513fbed" ac:name="code" ac:schema-version="1"><plain-text-body>zeroconf:_activemq_development.
</plain-text-body></structured-macro><p>This will use Zeroconf to find an available broker and one will be randomly chosen &amp; things will auto-failover on disconnect if there are several brokers running.</p><h3>LDAP Discovery</h3><p>ActiveMQ supports the use of LDAP for discovery of brokers.</p><p>Please see <link><page ri:content-title="LDAP Broker Discovery Mechanism"></page></link> for more details.</p><h2>Trying out discovery</h2><p>If you run the following commands in separate shells you'll have 2 brokers auto-discovering themselves and 2 clients using fixed-URLs</p><structured-macro ac:macro-id="11d9cbdf-33c7-4f54-b9b6-ebb80e6fdcc8" ac:name="code" ac:schema-version="1"><plain-text-body>maven -o server -Dconfig=src/test/org/activemq/usecases/receiver-zeroconf.xml
maven -o server -Dconfig=src/test/org/activemq/usecases/sender-zeroconf.xml
maven -o consumer -Durl=tcp://localhost:62002
maven -o producer -Durl=tcp://localhost:62001
</plain-text-body></structured-macro><p>If you want the clients to use discovery to find brokers, run either of the two 'server' statements above (or both) then run the producer/consumer as follows</p><structured-macro ac:macro-id="d61f046e-320e-45b1-8e46-119e1e612211" ac:name="code" ac:schema-version="1"><plain-text-body>maven -o consumer -Durl=zeroconf:_activemq.broker.development.
maven -o producer -Durl=zeroconf:_activemq.broker.development.
</plain-text-body></structured-macro><p>The transport URL is of the format</p><structured-macro ac:macro-id="fae97634-2d5e-41b9-9ae6-ed05d453676d" ac:name="code" ac:schema-version="1"><plain-text-body> zeroconf:&lt;serviceName&gt;
</plain-text-body></structured-macro><p>where <em>&lt;serviceName&gt;</em> is the Zeroconf service name; which seems to start with an underscore (_) and must end with a dot (.). So we can use this service name to distinguish development, UAT &amp; production brokers - or group them into domains etc.</p><h2>Discovery and Security</h2><p>When using auto discovery of brokers an attacker may be able to present itself as a legitimate broker and by this way catch and / or manipulate all messages that run over it.</p><p>Are there security settings in auto discovery to avoid this?</p></div>