134.3. 캐시 생산자 매핑 -("hazelcast-map:foo")
맵에 값을 저장하려면 맵 캐시 생산자를 사용할 수 있습니다.
맵 캐시 생산자는 CamelHazelcastOperationType 헤더에서 지정한 후속 작업을 제공합니다.
- put
- putIfAbsent
- get
- getAll
- keySet
- containsKey
- containsValue
- delete
- update
- query
- clear
- evict
- evictAll
모든 작업은 "hazelcast.operation.type" 헤더 변수 내에서 제공합니다. Java DSL에서는 org.apache.camel.component.hazelcast.HazelcastOperation
의 상수를 사용할 수 있습니다.
요청 메시지에 대한 헤더 변수:
이름 | 유형 | 설명 |
---|---|---|
|
| 이미 설명된 대로 |
|
| 캐시 내부에 오브젝트를 저장하고 저장할 오브젝트 ID입니다(쿼리 작업에는 필요하지 않음) |
put 및 putIfAbsent 작업은 제거 메커니즘을 제공합니다.
이름 | 유형 | 설명 |
---|---|---|
|
| TTL의 값. |
|
| 시간 단위 값(DAYS / HOURS / MINUTES / …. |
다음을 사용하여 샘플을 호출할 수 있습니다.
template.sendBodyAndHeader("direct:[put|get|update|delete|query|evict]", "my-foo", HazelcastConstants.OBJECT_ID, "4711");
134.3.1. 제품 상세 정보:
Java DSL:
from("direct:put") .setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.PUT)) .toF("hazelcast-%sfoo", HazelcastConstants.MAP_PREFIX);
Spring DSL:
<route> <from uri="direct:put" /> <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" --> <setHeader headerName="hazelcast.operation.type"> <constant>put</constant> </setHeader> <to uri="hazelcast-map:foo" /> </route>
제거가 포함된 샘플:
Java DSL:
from("direct:put") .setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.PUT)) .setHeader(HazelcastConstants.TTL_VALUE, constant(Long.valueOf(1))) .setHeader(HazelcastConstants.TTL_UNIT, constant(TimeUnit.MINUTES)) .toF("hazelcast-%sfoo", HazelcastConstants.MAP_PREFIX);
Spring DSL:
<route> <from uri="direct:put" /> <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" --> <setHeader headerName="hazelcast.operation.type"> <constant>put</constant> </setHeader> <setHeader headerName="HazelcastConstants.TTL_VALUE"> <simple resultType="java.lang.Long">1</simple> </setHeader> <setHeader headerName="HazelcastConstants.TTL_UNIT"> <simple resultType="java.util.concurrent.TimeUnit">TimeUnit.MINUTES</simple> </setHeader> <to uri="hazelcast-map:foo" /> </route>
134.3.2. get 에 대한 샘플:
Java DSL:
from("direct:get") .setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET)) .toF("hazelcast-%sfoo", HazelcastConstants.MAP_PREFIX) .to("seda:out");
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-map:foo" /> <to uri="seda:out" /> </route>
134.3.3. 업데이트 샘플:
Java DSL:
from("direct:update") .setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.UPDATE)) .toF("hazelcast-%sfoo", HazelcastConstants.MAP_PREFIX);
Spring DSL:
<route> <from uri="direct:update" /> <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" --> <setHeader headerName="hazelcast.operation.type"> <constant>update</constant> </setHeader> <to uri="hazelcast-map:foo" /> </route>
134.3.4. 삭제 샘플 :
Java DSL:
from("direct:delete") .setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DELETE)) .toF("hazelcast-%sfoo", HazelcastConstants.MAP_PREFIX);
Spring DSL:
<route> <from uri="direct:delete" /> <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" --> <setHeader headerName="hazelcast.operation.type"> <constant>delete</constant> </setHeader> <to uri="hazelcast-map:foo" /> </route>
134.3.5. 쿼리샘플
Java DSL:
from("direct:query") .setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.QUERY)) .toF("hazelcast-%sfoo", HazelcastConstants.MAP_PREFIX) .to("seda:out");
Spring DSL:
<route> <from uri="direct:query" /> <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" --> <setHeader headerName="hazelcast.operation.type"> <constant>query</constant> </setHeader> <to uri="hazelcast-map:foo" /> <to uri="seda:out" /> </route>
쿼리 작업 Hazelcast는 분산 맵을 쿼리하는 구문과 같은 SQL을 제공합니다.
String q1 = "bar > 1000"; template.sendBodyAndHeader("direct:query", null, HazelcastConstants.QUERY, q1);