<!-- 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 끝점에서 여러Consumers=true를 지정했기 때문에 두 개 이상의 소비자가 해당 메시지의 자체 사본을 kind-sub 스타일 메시징으로 받을 수 있습니다. Beans는 단위 테스트의 일부이므로 간단히 메시지를 모의 엔드포인트로 전송하지만 @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