搜索

此内容没有您所选择的语言版本。

Chapter 182. VM

download PDF

VM Component

The vm: component provides asynchronous SEDA behavior, exchanging messages on a BlockingQueue 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 camel-core.jar is on the system/boot classpath).
VM is an extension to the SEDA component.

URI format

vm:queueName[?options]
Where queueName can be any string to uniquely identify the endpoint within the JVM (or at least within the classloader that loaded camel-core.jar)
You can append query options to the URI in the following format: ?option=value&option=value&...
Before Camel 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 and the consumer endpoint. Otherwise, Camel will create a second VM endpoint despite that the queueName portion of the URI is identical. For example:
from("direct:foo").to("vm:bar?concurrentConsumers=5");

from("vm:bar?concurrentConsumers=5").to("file://output");
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 that only the queue name must match. Using the queue name bar, we could rewrite the previous exmple as follows:
from("direct:foo").to("vm:bar");

from("vm:bar?concurrentConsumers=5").to("file://output");

Options

See the SEDA component for options and other important usage details as the same rules apply to the VM component.

Samples

In the route below we send exchanges across CamelContext instances to a VM queue named order.email:
from("direct:in").bean(MyOrderBean.class).to("vm:order.email");
And then we receive exchanges in some other Camel context (such as deployed in another .war application):
from("vm:order.email").bean(MyOrderEmailSender.class);
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.