24.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 - リポジトリー Bean を設定する
- 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 - リポジトリー Bean を設定する
- 3 - リポジトリーをルートに設定する