blob: d5e83de53ab0a68f65389e3cfb8e1b9fa97d37a6 [file] [log] [blame]
<div class="wiki-content maincontent"><h3 id="VMTransportReference-TheVMTransport">The VM Transport</h3><p>The VM transport allows clients to connect to each other inside the VM without the overhead of the network communication. The connection used is not a socket connection but use direct method invocations which enables a high performance embedded messaging system.</p><p>The first client to use the VM connection will boot an embedded broker. Subsequent connections will attach that the same broker. Once all VM connections to the broker have been closed, the embedded broker will automatically shutdown.</p><h4 id="VMTransportReference-SimpleBrokerConfigurationSyntax">Simple Broker Configuration Syntax</h4><p>This is the normal syntax for a VM connection. It's simple, but provides only a limited amount of configuration of the embedded broker.</p><p><strong>vm://brokerName?transportOptions</strong></p><p>If you want to connect to an already instantiated, embedded broker (e.g. as in case the case of Apache ServiceMix), make sure the brokerName used in the <strong>vm://brokerName</strong> url matches the brokerName of the already running broker.</p><h5 id="VMTransportReference-TransportOptions">Transport Options</h5><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>marshal</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>false</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If true, forces each command sent over the transport to be marshalled and unmarshalled using a WireFormat</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>wireFormat</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>default</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The name of the WireFormat to use</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>wireFormat.*</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>All the properties with this prefix are used to configure the wireFormat</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>create</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>true</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If the broker should be created on demand if it does not already exist.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>waitForStart</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>-1</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If &gt; 0, indicates the timeout in milliseconds to wait for a broker to start. Values -1 and 0 mean don't wait. Only supported in ActiveMQ 5.2+</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>broker.*</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>All the properties with this prefix are used to configure the broker. See <a shape="rect" href="configuring-wire-formats.html">Configuring Wire Formats</a> for more information</p></td></tr></tbody></table></div><h5 id="VMTransportReference-ExampleURI">Example URI</h5><div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>vm://broker1?marshal=false&amp;broker.persistent=false
</pre>
</div></div><div class="confluence-information-macro confluence-information-macro-warning"><p class="title">Be careful with embedded brokers</p><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>If you are using the VM transport and wish to explicitly configure an <a shape="rect" href="how-do-i-embed-a-broker-inside-a-connection.html">Embedded Broker</a> there is a chance that you could create the JMS connections first before the broker starts up. Currently ActiveMQ will auto-create a broker if you use the VM transport and there is not one already configured. (In 5.2 it is possible to use the waitForStart and create=false options for the connection uri)</p><p>So to work around this if you are using Spring you may wish to use the <strong>depends-on</strong> attribute so that your JMS ConnectionFactory depends on the embedded broker to avoid this happening. e.g.</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;">&lt;bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean"&gt;
&lt;property name="config" value="classpath:org/apache/activemq/xbean/activemq.xml" /&gt;
&lt;property name="start" value="true" /&gt;
&lt;/bean&gt;
&lt;bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker"&gt;
&lt;property name="brokerURL" value="vm://localhost"/&gt;
&lt;/bean&gt;
</pre>
</div></div></div></div><h4 id="VMTransportReference-AdvancedBrokerConfigurationSyntax">Advanced Broker Configuration Syntax</h4><p>This is the advanced syntax for a VM connection. It's allows you configure the broker more extensively using a <a shape="rect" href="broker-configuration-uri.html">Broker Configuration URI</a>.</p><p><strong>vm:(broker:(tcp://localhost)?brokerOptions)?transportOptions</strong><br clear="none"> or<br clear="none"> <strong>vm:broker:(tcp://localhost)?brokerOptions</strong></p><h5 id="VMTransportReference-TransportOptions.1">Transport Options</h5><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>marshal</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>false</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If true, forces each command sent over the transport to be marshalled and unmarshalled using a WireFormat</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>wireFormat</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>default</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The name of the WireFormat to use</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>wireFormat.*</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>All the properties with this prefix are used to configure the wireFormat</p></td></tr></tbody></table></div><p>There are <a shape="rect" href="how-should-i-use-the-vm-transport.html">more options</a> on optimising the use of the VM transport.</p><h5 id="VMTransportReference-ExampleURI.1">Example URI</h5><div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>vm:(broker:(tcp://localhost:6000)?persistent=false)?marshal=false
</pre>
</div></div><h4 id="VMTransportReference-ConfiguringanEmbeddedBrokerUsinganExternalConfigFile">Configuring an Embedded Broker Using an External Config File</h4><p>&#160;To start an embedded broker using the vm transport and configure it using an external configuration file (i.e. activemq.xml), use the following URI:</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?brokerConfig=xbean:activemq.xml
</pre>
</div></div></div>