135.3. Multimap 캐시 생산자 -("hazelcast-multimap:foo")

다중 맵은 n 값을 하나의 키에 저장할 수 있는 캐시입니다. multimap 프로듀서는 4개의 작업(하루, get, removevalue, delete)을 제공합니다.

요청 메시지에 대한 헤더 변수:

이름유형설명

CamelHazelcastOperationType

문자열

유효한 값은 put, get, removevalue, delete From Camel 2.16: clear입니다.

CamelHazelcastObjectId

문자열

캐시 내에서 오브젝트를 저장/검색할 오브젝트 ID

135.3.1. 제품 상세 정보:

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" 값이 있는 경우 { "my-foo", "my-bar" }}를 메시지 본문에 배치하여 "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. 삭제 샘플 :

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");