blob: 0440f145c4992bfbcf368b8586ee95f7043cf104 [file] [log] [blame]
<div class="wiki-content maincontent"><h3>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>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>Transport Options</h5><table><tbody><tr><th colspan="1" rowspan="1"><p>Option Name</p></th><th colspan="1" rowspan="1"><p>Default Value</p></th><th colspan="1" rowspan="1"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1"><p>marshal</p></td><td colspan="1" rowspan="1"><p>false</p></td><td colspan="1" rowspan="1"><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"><p>wireFormat</p></td><td colspan="1" rowspan="1"><p>default</p></td><td colspan="1" rowspan="1"><p>The name of the WireFormat to use</p></td></tr><tr><td colspan="1" rowspan="1"><p>wireFormat.*</p></td><td colspan="1" rowspan="1"><p>&#160;</p></td><td colspan="1" rowspan="1"><p>All the properties with this prefix are used to configure the wireFormat</p></td></tr><tr><td colspan="1" rowspan="1"><p>create</p></td><td colspan="1" rowspan="1"><p>true</p></td><td colspan="1" rowspan="1"><p>If the broker should be created on demand if it does not already exist.</p></td></tr><tr><td colspan="1" rowspan="1"><p>waitForStart</p></td><td colspan="1" rowspan="1"><p>-1</p></td><td colspan="1" rowspan="1"><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"><p>broker.*</p></td><td colspan="1" rowspan="1"><p>&#160;</p></td><td colspan="1" rowspan="1"><p>All the properties with this prefix are used to configure the broker. See <link><page ri:content-title="Configuring Wire Formats"></page></link> for more information</p></td></tr></tbody></table><h5>Example URI</h5><structured-macro ac:macro-id="592b3ea5-9343-4135-a998-1059b4739023" ac:name="noformat" ac:schema-version="1"><plain-text-body>vm://broker1?marshal=false&amp;broker.persistent=false
</plain-text-body></structured-macro><structured-macro ac:macro-id="8ca9d826-7d1d-48db-bd15-5017980d4e12" ac:name="warning" ac:schema-version="1"><parameter ac:name="title">Be careful with embedded brokers</parameter><rich-text-body><p>If you are using the VM transport and wish to explicitly configure an <link><page ri:content-title="How do I embed a Broker inside a Connection"></page><plain-text-link-body>Embedded Broker</plain-text-link-body></link> 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><structured-macro ac:macro-id="1a5e5eea-9463-4a02-b30a-58726c93db80" ac:name="code" ac:schema-version="1"><plain-text-body>&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;
</plain-text-body></structured-macro></rich-text-body></structured-macro><h4>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 <link><page ri:content-title="Broker Configuration URI"></page></link>.</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>Transport Options</h5><table><tbody><tr><th colspan="1" rowspan="1"><p>Option Name</p></th><th colspan="1" rowspan="1"><p>Default Value</p></th><th colspan="1" rowspan="1"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1"><p>marshal</p></td><td colspan="1" rowspan="1"><p>false</p></td><td colspan="1" rowspan="1"><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"><p>wireFormat</p></td><td colspan="1" rowspan="1"><p>default</p></td><td colspan="1" rowspan="1"><p>The name of the WireFormat to use</p></td></tr><tr><td colspan="1" rowspan="1"><p>wireFormat.*</p></td><td colspan="1" rowspan="1"><p>&#160;</p></td><td colspan="1" rowspan="1"><p>All the properties with this prefix are used to configure the wireFormat</p></td></tr></tbody></table><p>There are <link><page ri:content-title="How should I use the VM transport"></page><plain-text-link-body>more options</plain-text-link-body></link> on optimising the use of the VM transport.</p><h5>Example URI</h5><structured-macro ac:macro-id="5c97b2c2-af39-4c1e-b6af-2a90be0c2100" ac:name="noformat" ac:schema-version="1"><plain-text-body>vm:(broker:(tcp://localhost:6000)?persistent=false)?marshal=false
</plain-text-body></structured-macro><h4>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><structured-macro ac:macro-id="ae9d03a5-7d07-4413-a210-21ecbeb9cb45" ac:name="code" ac:schema-version="1"><plain-text-body> vm://localhost?brokerConfig=xbean:activemq.xml
</plain-text-body></structured-macro></div>