122.11. multipleConsumers の使用
この例では、2 つの consumer を定義しました。
@Test
public void testSameOptionsProducerStillOkay() throws Exception {
getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:bar").expectedBodiesReceived("Hello World");
template.sendBody("seda:foo", "Hello World");
assertMockEndpointsSatisfied();
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("seda:foo?multipleConsumers=true").routeId("foo").to("mock:foo");
from("seda:foo?multipleConsumers=true").routeId("bar").to("mock:bar");
}
};
}
seda foo エンドポイントで multipleConsumers=true を指定したので、これら 2 つの consumer に、一種の pub-sub スタイルメッセージングとしてメッセージの独自のコピーを受信させることができます。
Bean は単体テストの一部であるため、単純にメッセージをモックエンドポイントに送信します。