<!-- define the consumers as spring beans -->
<bean id="consumer1" class="org.apache.camel.spring.example.FooEventConsumer"/>
<bean id="consumer2" class="org.apache.camel.spring.example.AnotherFooEventConsumer"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- define a shared endpoint which the consumers can refer to instead of using url -->
<endpoint id="foo" uri="disruptor:foo?multipleConsumers=true"/>
</camelContext>
<!-- define the consumers as spring beans -->
<bean id="consumer1" class="org.apache.camel.spring.example.FooEventConsumer"/>
<bean id="consumer2" class="org.apache.camel.spring.example.AnotherFooEventConsumer"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- define a shared endpoint which the consumers can refer to instead of using url -->
<endpoint id="foo" uri="disruptor:foo?multipleConsumers=true"/>
</camelContext>
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Disruptor foo endpoint에 여러Consumers=true를 지정했기 때문에 두 개 이상의 소비자가 메시지 사본을 pub-sub 스타일 메시지 유형으로 수신할 수 있습니다. 빈이 단위 테스트의 일부이므로 mock 엔드포인트에 메시지를 보낼 수 있지만, @Consume를 사용하여 Disruptor에서 사용할 수 있는 방법을 확인할 수 있습니다.
public class FooEventConsumer {
@EndpointInject(uri = "mock:result")
private ProducerTemplate destination;
@Consume(ref = "foo")
public void doSomething(String body) {
destination.sendBody("foo" + body);
}
}
public class FooEventConsumer {
@EndpointInject(uri = "mock:result")
private ProducerTemplate destination;
@Consume(ref = "foo")
public void doSomething(String body) {
destination.sendBody("foo" + body);
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow