23.8. Infinispan 기반 멱등 리포지토리 사용
이 섹션에서는 Infinispan 기반 멱등 리포지토리를 사용합니다.
Java 예
InfinispanRemoteConfiguration conf = new InfinispanRemoteConfiguration(); (1)
conf.setHosts("localhost:1122")
InfinispanRemoteIdempotentRepository repo = new InfinispanRemoteIdempotentRepository("idempotent"); (2)
repo.setConfiguration(conf);
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("direct:start")
.idempotentConsumer(header("MessageID"), repo) (3)
.to("mock:result");
}
});
다음과 같습니다.
- 1 - 캐시 구성
- 2 - 리포지토리 빈 구성
- 3 - 리포지터리를 경로로 설정
XML 예
<bean id="infinispanRepo" class="org.apache.camel.component.infinispan.remote.InfinispanRemoteIdempotentRepository" destroy-method="stop">
<constructor-arg value="idempotent"/> (1)
<property name="configuration"> (2)
<bean class="org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration">
<property name="hosts" value="localhost:11222"/>
</bean>
</property>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start" />
<idempotentConsumer messageIdRepositoryRef="infinispanRepo"> (3)
<header>MessageID</header>
<to uri="mock:result" />
</idempotentConsumer>
</route>
</camelContext>
다음과 같습니다.
- 1 - 저장소에서 사용할 캐시의 이름을 설정합니다.
- 2 - 리포지토리 빈 구성
- 3 - 리포지터리를 경로로 설정