blob: 7a94fd234562563624e26f86f0772f069e913e78 [file] [log] [blame]
<div class="wiki-content maincontent"><p>ActiveMQ is designed to support mutliple different <a shape="rect" href="topologies.html">topologies</a> 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 <a shape="rect" href="configuring-transports.html">transports</a> supported. You can specify the connection URL on an <a shape="rect" class="external-link" 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>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://somehost:61616");
Connection connection = factory.createConnection();
</pre>
</div></div>
<h2 id="URIProtocols-ProtocolSummary">Protocol Summary</h2>
<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Protocol</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Example</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Server?</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>VM</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>vm://host:port</p></td><td colspan="1" rowspan="1" class="confluenceTd"><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>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">vm://localhost?async=false</pre>
</div></div></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Yes</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>TCP</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>tcp://host:port</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Client connects to the broker at the given URL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Yes</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>SSL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>ssl://host:port</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Client connects to the broker at the given URL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Yes</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Failover</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>failover:(Uri1,Uri2,Uri3,...,UriN)</p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Peer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>peer://serviceName</p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Discovery</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>discovery://host:port</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Uses <a shape="rect" href="discovery.html">Discovery</a> 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" class="confluenceTd"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Zeroconf</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>zeroconf:_activemq.broker.development.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Uses <a shape="rect" href="zeroconf.html">Zeroconf</a> 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" class="confluenceTd"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>HTTP</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>http://host:port</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Client connects to the broker using HTTP tunnelling, with XML payloads suitable for going through firewalls</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Yes</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>UDP</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>udp://host:port</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Client connects to the broker at the given URL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>multicast</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>multicast://host:port</p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p>&#160;</p></td></tr></tbody></table></div>
<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" class="external-link" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnectionFactory.html">ActiveMQConnectionFactory</a>.</p>
<p>Please refer to the <a shape="rect" href="topologies.html">topologies overview</a> to see how we can use ActiveMQ in many different topologies to suit your messaging needs.</p>
<h3 id="URIProtocols-SpecifyingmultipleURLstoconnectto">Specifying multiple URLs to connect to</h3>
<p>If you want full <a shape="rect" href="ha.html">HA</a> to provide failover and auto-reconnection you can use the <em>failover:</em> prefix</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
failover:(tcp://foo:61699,tcp://bar:61617,tcp://whatnot:61698)
</pre>
</div></div>
<p>see <a shape="rect" href="configuring-transports.html">Configuring Transports</a> for more details</p></div>