多个消费者都有返回值时,报错

12-08-23 selayou
多个消费者都有返回值时

@Consuemr("topic")

ConsumerA{

Onevent(EventDisruptor Event boolean endofbantch){

event.getDomainmEssage().setEventResult(result);

}

}

@Consumer("topic")

ConsumerB{

Onevent(EventDisruptor Event boolean endofbantch){

event.getDomainmEssage().setEventResult(result);

}

}

两个Consumer都是“topic”的消费者,每个都返回执行结果result,后面一个会报错!

麻烦banq回答下

thanks a lot

banq
2012-08-23 10:40
2012-08-23 10:38 "@selayou"的内容
两个Consumer都是“topic”的消费者,每个都返回执行结果result,后面一个会报错 ...

一个bug,到git下载最新版本即可

selayou
2012-08-23 21:09
还有问,不知道返回的结果是根据什么规则,最先返回的,还是最后返回的

banq
2012-08-23 21:11
最后返回。

selayou
2012-08-24 10:52
我测试了下,但是还是最先返回的那个Consumer的结果。在DisruptorFactoryTest

public void testGetDisruptor() {

TreeSet<DomainEventHandler> handlers = disruptorFactory.getTreeSet();

final DomainEventHandler<EventDisruptor> handler = new DomainEventHandler<EventDisruptor>() {

public void onEvent(EventDisruptor event, final boolean endOfBatch) throws Exception {

System.out.println("MyEventA=" + event.getDomainMessage().getEventSource());

event.getDomainMessage().setEventResult(11111 + (Long) event.getDomainMessage().getEventSource());

}

};

final DomainEventHandler<EventDisruptor> handler2 = new DomainEventHandler<EventDisruptor>() {

public void onEvent(EventDisruptor event, final boolean endOfBatch) throws Exception {

System.out.println("MyEventA=" + event.getDomainMessage().getEventSource());

event.getDomainMessage().setEventResult(22222 + (Long) event.getDomainMessage().getEventSource());

}

};

handlers.add(handler2);

handlers.add(handler);

因为按照类名排序的,handler总是排在前面,类名com.jdon.async.disruptor.DisruptorFactoryTest$1,

handler2总是排在后面类名是com.jdon.async.disruptor.DisruptorFactoryTest$2

返回的总是hander的结果

猜你喜欢
3Go 1 2 3 下一页