138.3. replicatedmap 缓存制作者
replicatedmap producer 提供 4 个操作:
请求消息的标头变量:
名称 | 类型 | 描述 |
---|---|---|
|
| 有效值为: put, get, removevalue, delete |
|
| 在缓存中存储 / 的对象 id |
138.3.1. 放置 的示例:
Java DSL:
from("direct:put") .setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.PUT)) .to(String.format("hazelcast-%sbar", HazelcastConstants.REPLICATEDMAP_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-replicatedmap:foo" /> </route>
138.3.2. get 的示例:
Java DSL:
from("direct:get") .setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET)) .toF("hazelcast-%sbar", HazelcastConstants.REPLICATEDMAP_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-replicatedmap:foo" /> <to uri="seda:out" /> </route>
138.3.3. 删除 示例:
Java DSL:
from("direct:delete") .setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DELETE)) .toF("hazelcast-%sbar", HazelcastConstants.REPLICATEDMAP_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-replicatedmap:foo" /> </route>
您可以使用以下方法在测试类中调用它们:
template.sendBodyAndHeader("direct:[put|get|delete|clear]", "my-foo", HazelcastConstants.OBJECT_ID, "4711");