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

5.2. Routing with Camel in JBoss Data Grid


Camel routing is a chain of processors that move messages in the background. The following is an example of a route that retrieves a value from the cache for a specific key.
from("direct:start")
        .setHeader(InfinispanConstants.OPERATION, constant(InfinispanConstants.GET))
        .setHeader(InfinispanConstants.KEY, constant("123"))
        .to("infinispan://localhost?cacheContainer=#cacheContainer");
Copy to Clipboard Toggle word wrap
Routing can also be performed using XML configuration. The following example demonstrates camel-jbossdatagrid's Local Camel Producer, a camel route that uses the camel-jbossdatagrid component to send data to an embedded cache created by the local-cache module.
<camelContext id="local-producer" xmlns="http://camel.apache.org/schema/blueprint">
	<route>
		<from uri="timer://local?fixedRate=true&amp;period=5000"/>
		<setHeader headerName="CamelInfinispanKey">
			<property>CamelTimerCounter</property>
		</setHeader>
		<setHeader headerName="CamelInfinispanValue">
			<property>CamelTimerCounter</property>
		</setHeader>
		<to uri="infinispan://foo?cacheContainer=#cacheManager"/>
		<to uri="log:local-put?showAll=true"/>
	</route>
</camelContext>
Copy to Clipboard Toggle word wrap
The provided example requires the cacheManager to be instantiated.
The cacheManager bean for Spring XML can be instantiated as follows:
<bean id="cacheManager" class="org.infinispan.manager.DefaultCacheManager" init-method="start" destroy-method="stop">
  <constructor-arg type="java.lang.String" value="infinispan.xml"/>
</bean>
Copy to Clipboard Toggle word wrap
The following demonstrates how to instantiate the cacheManager bean using Blueprint XML.
<bean id="cacheManager" class="org.infinispan.manager.DefaultCacheManager" init-method="start" destroy-method="stop">
      <argument value="infinispan.xml" />
</bean>
Copy to Clipboard Toggle word wrap

Note

Both the Spring XML and Blueprint XML examples use the configuration file infinispan.xml for configuration of the cache. This file must be present on the classpath.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat