이 콘텐츠는 선택한 언어로 제공되지 않습니다.
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");
from("direct:start")
.setHeader(InfinispanConstants.OPERATION, constant(InfinispanConstants.GET))
.setHeader(InfinispanConstants.KEY, constant("123"))
.to("infinispan://localhost?cacheContainer=#cacheContainer");
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.
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>
<bean id="cacheManager" class="org.infinispan.manager.DefaultCacheManager" init-method="start" destroy-method="stop">
<constructor-arg type="java.lang.String" value="infinispan.xml"/>
</bean>
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>
<bean id="cacheManager" class="org.infinispan.manager.DefaultCacheManager" init-method="start" destroy-method="stop">
<argument value="infinispan.xml" />
</bean>
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.