132.3. Atomic number producer - to"hazelcast-atomicvalue:foo")
此制作者的操作包括:* setvalue (使用给定值设置号)* get * increase (+1)* 减少(-1)* destroy
请求消息的标头变量:
| Name | 类型 | 描述 |
|---|---|---|
|
|
| 有效值有:setvalue, get, increase, decrease, destroy |
132.3.1. 设置 示例: 复制链接链接已复制到粘贴板!
Java DSL:
from("direct:set")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.SET_VALUE))
.toF("hazelcast-%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);
Spring DSL:
<route>
<from uri="direct:set" />
<!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
<setHeader headerName="hazelcast.operation.type">
<constant>setvalue</constant>
</setHeader>
<to uri="hazelcast-atomicvalue:foo" />
</route>
提供要在消息正文中设置的值(其中值为 10): template.sendBody ("direct:set", 10);
132.3.2. get 的示例: 复制链接链接已复制到粘贴板!
Java DSL:
from("direct:get")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET))
.toF("hazelcast-%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);
Spring DSL:
<route>
<from uri="direct:get" />
<!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
<setHeader headerName="hazelcast.operation.type">
<constant>get</constant>
</setHeader>
<to uri="hazelcast-atomicvalue:foo" />
</route>
您可以使用 较长的 body = template.requestBody ("direct:get", null, Long.class) 获取数字,。
132.3.3. 递增 示例: 复制链接链接已复制到粘贴板!
Java DSL:
from("direct:increment")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.INCREMENT))
.toF("hazelcast-%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);
Spring DSL:
<route>
<from uri="direct:increment" />
<!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
<setHeader headerName="hazelcast.operation.type">
<constant>increment</constant>
</setHeader>
<to uri="hazelcast-atomicvalue:foo" />
</route>
实际值(递增后)将在消息正文中提供。
132.3.4. 减少 示例: 复制链接链接已复制到粘贴板!
Java DSL:
from("direct:decrement")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DECREMENT))
.toF("hazelcast-%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);
Spring DSL:
<route>
<from uri="direct:decrement" />
<!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
<setHeader headerName="hazelcast.operation.type">
<constant>decrement</constant>
</setHeader>
<to uri="hazelcast-atomicvalue:foo" />
</route>
实际值(减少后)将在消息正文中提供。
132.3.5. destroy的示例 复制链接链接已复制到粘贴板!
Java DSL:
from("direct:destroy")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DESTROY))
.toF("hazelcast-%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);
Spring DSL:
<route>
<from uri="direct:destroy" />
<!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
<setHeader headerName="hazelcast.operation.type">
<constant>destroy</constant>
</setHeader>
<to uri="hazelcast-atomicvalue:foo" />
</route>