131.2. 使用 hazelcast 参考
131.2.1. 按名称
<bean id="hazelcastLifecycle" class="com.hazelcast.core.LifecycleService" factory-bean="hazelcastInstance" factory-method="getLifecycleService" destroy-method="shutdown" /> <bean id="config" class="com.hazelcast.config.Config"> <constructor-arg type="java.lang.String" value="HZ.INSTANCE" /> </bean> <bean id="hazelcastInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"> <constructor-arg type="com.hazelcast.config.Config" ref="config"/> </bean> <camelContext xmlns="http://camel.apache.org/schema/spring"> <route id="testHazelcastInstanceBeanRefPut"> <from uri="direct:testHazelcastInstanceBeanRefPut"/> <setHeader headerName="CamelHazelcastOperationType"> <constant>put</constant> </setHeader> <to uri="hazelcast-map:testmap?hazelcastInstanceName=HZ.INSTANCE"/> </route> <route id="testHazelcastInstanceBeanRefGet"> <from uri="direct:testHazelcastInstanceBeanRefGet" /> <setHeader headerName="CamelHazelcastOperationType"> <constant>get</constant> </setHeader> <to uri="hazelcast-map:testmap?hazelcastInstanceName=HZ.INSTANCE"/> <to uri="seda:out" /> </route> </camelContext>
131.2.2. 按实例
<bean id="hazelcastInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance" /> <bean id="hazelcastLifecycle" class="com.hazelcast.core.LifecycleService" factory-bean="hazelcastInstance" factory-method="getLifecycleService" destroy-method="shutdown" /> <camelContext xmlns="http://camel.apache.org/schema/spring"> <route id="testHazelcastInstanceBeanRefPut"> <from uri="direct:testHazelcastInstanceBeanRefPut"/> <setHeader headerName="CamelHazelcastOperationType"> <constant>put</constant> </setHeader> <to uri="hazelcast-map:testmap?hazelcastInstance=#hazelcastInstance"/> </route> <route id="testHazelcastInstanceBeanRefGet"> <from uri="direct:testHazelcastInstanceBeanRefGet" /> <setHeader headerName="CamelHazelcastOperationType"> <constant>get</constant> </setHeader> <to uri="hazelcast-map:testmap?hazelcastInstance=#hazelcastInstance"/> <to uri="seda:out" /> </route> </camelContext>