126.2. map cache producer - to("hazelcast-map:foo")
値をマップに保存する場合は、マップキャッシュプロデューサーを使用できます。
map キャッシュプロデューサーは、CamelHazelcastOperationType ヘッダーによって指定される以下の操作を提供します。
- put
- putIfAbsent
- get
- getAll
- keySet
- containsKey
- containsValue
- 削除
- 更新
- query
- 明確な
- エビクト
- evictAll
すべての操作は、「hazelcast.operation.type」ヘッダー変数内に提供されます。Java DSL では、org.apache.camel.component.hazelcast.HazelcastOperation
からの定数を使用できます。
リクエストメッセージのヘッダー変数:
Name | タイプ | 説明 |
---|---|---|
|
| すでに説明されているようにしてあります。 |
|
| 保存するオブジェクト ID。キャッシュ内でオブジェクトを検索します(クエリー操作には必要ありません)。 |
put および putIfAbsent 操作はエビクションメカニズムを提供します。
Name | タイプ | 説明 |
---|---|---|
|
| TTL の値。 |
|
| 時間単位の値(DAYS / HOURS / MINUTES / … |
以下を使用してサンプルを呼び出すことができます。
template.sendBodyAndHeader("direct:[put|get|update|delete|query|evict]", "my-foo", HazelcastConstants.OBJECT_ID, "4711");
126.2.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>