The VM Transport
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.
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.
Simple Broker Configuration Syntax
This is the normal syntax for a VM connection. It's simple, but provides only a limited amount of configuration of the embedded broker.
vm://brokerName?transportOptions
Transport Options
| Option Name |
Default Value |
Description |
| marshal |
false |
If true, forces each command sent over the transport to be marshlled and unmarshlled using a WireFormat |
| wireFormat |
default |
The name of the WireFormat to use |
| wireFormat.* |
|
All the properties with this prefix are used to configure the wireFormat |
| create |
true |
If the broker should be created on demand if it does not allready exist. Only supported in ActiveMQ 4.1 |
| broker.* |
|
All the properties with this prefix are used to configure the broker. See Configuring Wire Formats for more information |
Example URI
Advanced Broker Configuration Syntax
This is the advanced syntax for a VM connection. It's allows you configure the broker more extensively using a Broker Configuration URI.
vm:(broker:(tcp://localhost)?brokerOptions)?transportOptions
or
vm:broker:(tcp://localhost)?brokerOptions
Transport Options
| Option Name |
Default Value |
Description |
| marshal |
false |
If true, forces each command sent over the transport to be marshlled and unmarshlled using a WireFormat |
| wireFormat |
default |
The name of the WireFormat to use |
| wireFormat.* |
|
All the properties with this prefix are used to configure the wireFormat |
There are more options on optimising the use of the VM transport.
Example URI
Configuring an Embedded Broker Using an External Config File
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:
 | Be careful with embedded brokers
If you are using the VM transport and wish to explicitly configure an Embedded Broker 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.
So to work around this if you are using Spring you may wish to use the depends-on attribute so that your JMS ConnectionFactory depends on the embedded broker to avoid this happenning. e.g.
<bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean">
<property name="config" value="classpath:org/apache/activemq/xbean/activemq.xml" />
<property name="start" value="true" />
</bean>
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker">
<property name="brokerURL" value="vm:/>
</bean>
|