blob: e4e38b754aa9ca73e0cba17a10be43239764c21f [file] [log] [blame]
<div class="wiki-content maincontent"><p>ActiveMQ is designed to support mutliple different <link><page ri:content-title="Topologies"></page><link-body>topologies</link-body></link> and protocols. Which one you use depends on your messaging requirements, quality of service and network topology.</p>
<p>The following table describes the different network protocols available for JMS clients along with showing the connection URL string you use to enable this communication protocol. On the broker side there are additional <link><page ri:content-title="Configuring Transports"></page><link-body>transports</link-body></link> supported. You can specify the connection URL on an <a shape="rect" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnectionFactory.html">ActiveMQConnectionFactory</a> (in a constructor or via the brokerURL property). </p>
<p>e.g. if you don't want to bother setting up JNDI and so forth and just wanna create a JMS connection you can do something like</p>
<structured-macro ac:macro-id="c324de2c-ad21-4ce2-a05d-19979b731e52" ac:name="code" ac:schema-version="1"><plain-text-body>
ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://somehost:61616");
Connection connection = factory.createConnection();
</plain-text-body></structured-macro>
<h2>Protocol Summary</h2>
<table><tbody><tr><th colspan="1" rowspan="1"><p>Protocol</p></th><th colspan="1" rowspan="1"><p>Example</p></th><th colspan="1" rowspan="1"><p>Description</p></th><th colspan="1" rowspan="1"><p>Server?</p></th></tr><tr><td colspan="1" rowspan="1"><p>VM</p></td><td colspan="1" rowspan="1"><p>vm://host:port</p></td><td colspan="1" rowspan="1"><p>Client connect to each other within the same JVM. This does use an asynchronous channel and a separate worker thread. You can enable sync sending using a query parameter, such as </p>
<structured-macro ac:macro-id="5dc9ba8b-03f9-42ef-b042-54331d034cbe" ac:name="code" ac:schema-version="1"><plain-text-body>vm://localhost?async=false</plain-text-body></structured-macro></td><td colspan="1" rowspan="1"><p>Yes</p></td></tr><tr><td colspan="1" rowspan="1"><p>TCP</p></td><td colspan="1" rowspan="1"><p>tcp://host:port</p></td><td colspan="1" rowspan="1"><p>Client connects to the broker at the given URL</p></td><td colspan="1" rowspan="1"><p>Yes</p></td></tr><tr><td colspan="1" rowspan="1"><p>SSL</p></td><td colspan="1" rowspan="1"><p>ssl://host:port</p></td><td colspan="1" rowspan="1"><p>Client connects to the broker at the given URL</p></td><td colspan="1" rowspan="1"><p>Yes</p></td></tr><tr><td colspan="1" rowspan="1"><p>Failover</p></td><td colspan="1" rowspan="1"><p>failover:(Uri1,Uri2,Uri3,...,UriN)</p></td><td colspan="1" rowspan="1"><p>Provides a list of possible URIs to connect to and one is randomly chosen. If the connection fails then the transport auto-reconnects to a different one</p></td><td colspan="1" rowspan="1"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1"><p>Peer</p></td><td colspan="1" rowspan="1"><p>peer://serviceName</p></td><td colspan="1" rowspan="1"><p>Creates a pure peer to peer network of nodes of a given service name. In peer mode there is no server, nodes just automatically connect and make a peer network. The serviceName allows you to keep networks apart from each other, such as development, testing, UAT and production.</p></td><td colspan="1" rowspan="1"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1"><p>Discovery</p></td><td colspan="1" rowspan="1"><p>discovery://host:port</p></td><td colspan="1" rowspan="1"><p>Uses <link><page ri:content-title="Discovery"></page></link> to connect to an available broker of the correct channel name. If multiple brokers can be found then one is chosen at random. If the connection fails then another broker is chosen, if available</p></td><td colspan="1" rowspan="1"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1"><p>Zeroconf</p></td><td colspan="1" rowspan="1"><p>zeroconf:_activemq.broker.development.</p></td><td colspan="1" rowspan="1"><p>Uses <link><page ri:content-title="Zeroconf"></page></link> to connect to an available broker of the correct Zeroconf service name. If multiple brokers can be found then one is chosen at random. If the connection fails then another broker is chosen, if available</p></td><td colspan="1" rowspan="1"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1"><p>HTTP</p></td><td colspan="1" rowspan="1"><p>http://host:port</p></td><td colspan="1" rowspan="1"><p>Client connects to the broker using HTTP tunnelling, with XML payloads suitable for going through firewalls</p></td><td colspan="1" rowspan="1"><p>Yes</p></td></tr><tr><td colspan="1" rowspan="1"><p>UDP</p></td><td colspan="1" rowspan="1"><p>udp://host:port</p></td><td colspan="1" rowspan="1"><p>Client connects to the broker at the given URL</p></td><td colspan="1" rowspan="1"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1"><p>multicast</p></td><td colspan="1" rowspan="1"><p>multicast://host:port</p></td><td colspan="1" rowspan="1"><p>No server, though only works for pub/sub. A pure peer based network where all traffic is multicasted around and filtering is performed on the client.</p></td><td colspan="1" rowspan="1"><p>&#160;</p></td></tr></tbody></table>
<p>The <em>Server?</em> column above indiciates whether or not a protocol can be used in an ActiveMQ broker transport connector. All of the above protocols can be used in a JMS client to connect to the messaging fabric; only those protocols indicated can be used in a broker-side transport connector.</p>
<p>When connecting to an ActiveMQ broker, this could reside locally inside your JVM or be remote on another machine somewhere. If you want to enable the deployment of the ActiveMQ inside your JVM you can enable the useEmbeddedBroker property on the <a shape="rect" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnectionFactory.html">ActiveMQConnectionFactory</a>.</p>
<p>Please refer to the <link><page ri:content-title="Topologies"></page><link-body>topologies overview</link-body></link> to see how we can use ActiveMQ in many different topologies to suit your messaging needs.</p>
<h3>Specifying multiple URLs to connect to</h3>
<p>If you want full <link><page ri:content-title="HA"></page></link> to provide failover and auto-reconnection you can use the <em>failover:</em> prefix</p>
<structured-macro ac:macro-id="c4cb2d3e-3e3e-44c1-907d-5cc1903340d2" ac:name="code" ac:schema-version="1"><plain-text-body>
failover:(tcp://foo:61699,tcp://bar:61617,tcp://whatnot:61698)
</plain-text-body></structured-macro>
<p>see <link><page ri:content-title="Configuring Transports"></page></link> for more details</p></div>