135.3. multimap cache producer - to("hazelcast-multimap:foo")
multimap は、n 個の値を 1 つのキーに格納できるキャッシュです。multimap プロデューサーは、4 つの操作 (put、get、removevalue、delete) を提供します。
リクエストメッセージのヘッダー変数:
| 名前 | タイプ | 説明 |
|---|---|---|
|
|
| 有効な値は次のとおりです: put、get、removevalue、delete Camel 2.16 以降: clear。 |
|
|
| キャッシュ内でオブジェクトを保存/検索するためのオブジェクト ID |
135.3.1. put のサンプル:
Java DSL の場合
from("direct:put")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.PUT))
.to(String.format("hazelcast-%sbar", HazelcastConstants.MULTIMAP_PREFIX));Spring DSL:
<route>
<from uri="direct:put" />
<log message="put.."/>
<!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
<setHeader headerName="hazelcast.operation.type">
<constant>put</constant>
</setHeader>
<to uri="hazelcast-multimap:foo" />
</route>135.3.2. removevalue のサンプル:
Java DSL の場合
from("direct:removevalue")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.REMOVE_VALUE))
.toF("hazelcast-%sbar", HazelcastConstants.MULTIMAP_PREFIX);Spring DSL:
<route>
<from uri="direct:removevalue" />
<log message="removevalue..."/>
<!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
<setHeader headerName="hazelcast.operation.type">
<constant>removevalue</constant>
</setHeader>
<to uri="hazelcast-multimap:foo" />
</route>
値を削除するには、メッセージボディー内で削除する値を指定する必要があります。マルチマップオブジェクト \{key: "4711" values: { "my-foo", "my-bar"}} がある場合、メッセージボディーの中に my-foo を入れて my-foo 値を削除する必要があります。
135.3.3. get のサンプル:
Java DSL の場合
from("direct:get")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET))
.toF("hazelcast-%sbar", HazelcastConstants.MULTIMAP_PREFIX)
.to("seda:out");Spring DSL:
<route>
<from uri="direct:get" />
<log message="get.."/>
<!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
<setHeader headerName="hazelcast.operation.type">
<constant>get</constant>
</setHeader>
<to uri="hazelcast-multimap:foo" />
<to uri="seda:out" />
</route>135.3.4. delete のサンプル:
Java DSL の場合
from("direct:delete")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DELETE))
.toF("hazelcast-%sbar", HazelcastConstants.MULTIMAP_PREFIX);Spring DSL:
<route>
<from uri="direct:delete" />
<log message="delete.."/>
<!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
<setHeader headerName="hazelcast.operation.type">
<constant>delete</constant>
</setHeader>
<to uri="hazelcast-multimap:foo" />
</route>以下を使用して、テストクラスでそれらを呼び出すことができます。
template.sendBodyAndHeader("direct:[put|get|removevalue|delete]", "my-foo", HazelcastConstants.OBJECT_ID, "4711");