h2. VM Component
|
The *vm:* component provides asynchronous [SEDA|http://www.eecs.harvard.edu/~mdw/proj/seda/] behavior so that messages are exchanged on a [BlockingQueue|http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html] and consumers are invoked in a separate thread pool to the producer.
|
The *vm:* component provides asynchronous [SEDA|http://www.eecs.harvard.edu/~mdw/proj/seda/] behavior, exchanging messages on a [BlockingQueue|http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html] and invoking consumers in a separate thread pool.
|
|
This component differs from the [Seda] component in that VM supports communication across CamelContext instances, so you can use this mechanism to communicate across web applications, provided that the {{camel-core.jar}} is on the {{system/boot}} classpath.
|
This component differs from the [Seda] component in that VM supports communication across CamelContext instances - so you can use this mechanism to communicate across web applications (provided that {{camel-core.jar}} is on the {{system/boot}} classpath).
|
This component is an extension to the [Seda] component.
|
...
|
{code}
|
Where *someName* can be any string to uniquely identify the endpoint within the JVM (or at least within the classloader which that loaded the camel-core.jar)
|
|
You can append query options to the URI in the following format,: {{?option=value&option=value&...}}
|
{info:title=Camel 1.x to 2.3 - Same URI must be used for both producer and consumer}
|
An exactly identical [VM] endpoint URI *must* be used for both the producer endpoint and the consumer endpoint. Otherwise, Camel will create a second [VM] endpoint, even thought endpoint despite that the {{someName}} portion of the URI is identical. For example:
|
{code:java}
|
from("direct:foo").to("vm:bar?concurrentConsumers=5"); from("vm:bar?concurrentConsumers=5").to("file://output"); {code}
|
Notice that we have to use the full URI, including options in both the producer and consumer.
|
|
In Camel 2.4 this has been fixed so its the queue name that must match, eg in this example we are using bar as the queue name.
|
In Camel 2.4 this has been fixed so that only the queue name must match. Using the queue name {{bar}}, we could rewrite the previous exmple as follows: {code:java} from("direct:foo").to("vm:bar"); from("vm:bar?concurrentConsumers=5").to("file://output"); {code}
|
{info} h3. Options
|
See the [Seda] component for options and other important usage details as the same rules applies for this apply to the [Vm] component.
|
h3. Samples
|
In the route below we send the exchange to the VM queue that is working across CamelContext instances:
|
In the route below we send exchanges across CamelContext instances to a VM queue named {{order.email}}:
|
{code:java}
|
...
|
{code}
|
And then in another Camel context such as deployed as in another {{.war}} application:
|
And then we receive exchanges in some other Camel context (such as deployed in another {{.war}} application):
|
{code:java} from("vm:order.email").bean(MyOrderEmailSender.class);
|
...
|