131.3. Atomic 번호 생산자 - ~("hazelcast-atomicvalue:foo")
이 생산자의 작업은 * setvalue (특정 값이 있는 숫자 설정) * get * increase (+1) * decrease (-1) * destroy입니다.
요청 메시지에 대한 헤더 변수:
이름 | 유형 | 설명 |
---|---|---|
|
| 유효한 값은 setvalue, get, increase, decrease, destroy |
131.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
).
131.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)
를 사용하여 번호를 가져올 수 있습니다.
131.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>
실제 값(순간 후)은 메시지 본문 내에 제공됩니다.
131.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>
실제 값(종료 후)은 메시지 본문 내에 제공됩니다.
131.3.5. 삭제를 위한 샘플
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>