132.3. atomic number producer - to("hazelcast-atomicvalue:foo")
このプロデューサの操作は次のとおりです。* setvalue (set the number with a given value) * get * increase (+1) * decrease (-1) * destroy
リクエストメッセージのヘッダー変数:
名前 | 型 | 説明 |
---|---|---|
|
| 有効な値は次のとおりです: setvalue、get、increase、decrew、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>
long body = template.requestBody("direct:get", null, Long.class);
で数値を取得できます。
132.3.3. increment のサンプル:
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. decrement のサンプル:
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>