...
vm://brokerName?transportOptions
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 vm://brokerName url matches the brokerName of the already running broker.
Transport Options
Option Name |
Default Value |
Description |
marshal |
false |
If true, forces each command sent over the transport to be marshalled and unmarshalled 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 already exist. |
waitForStart |
-1 |
If > 0, indicates the timeout in milliseconds to wait for a broker to start. Only supported in ActiveMQ 5.2+ |
broker.* |
|
All the properties with this prefix are used to configure the broker. See Configuring Wire Formats for more information |
Example URI
No Format |
vm://broker1?marshal=false&broker.persistent=false
|
Warning |
title |
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. (In 5.2 it is possible to use the waitForStart and create=false options for the connection uri) 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 happening. e.g.
Code Block |
<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://localhost"/>
</bean>
|
|
...
There are more options on optimising the use of the VM transport.
Example URI
No Format |
vm:(broker:(tcp://localhost:6000)?persistent=false)?marshal=false
|
...
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:
Code Block |
vm://localhost?brokerConfig=xbean:activemq.xml
|