axon中event的问题

    
tecentIDA8F53 13-12-12

最近试用了下axon,遇到一个很奇怪的现象,AbstractEventSourcedAggregateRoot中apply发出的event,只能在当前AggregateRoot中接收到,外部的Listener无法接收到,而eventBus发的event,外部的Listener能收到,AggregateRoot收不到,我翻遍了AbstractEventSourcedAggregateRoot的所有基类,都没发现他对eventBus有引用,所以他们两个的event其实不是一回事,这是啥情况,有用过axon的童鞋能解答下么

tecentIDA8F53
2013-12-12 17:27

我看了下apply的注释:The event is applied on all entities part of this aggregate.
难道aggregate中的事件是不被外部Listener所共享的?这又是为何

banq
2013-12-12 21:36


2013-12-12 17:27 "@
tecentIDA8F53"的内容
难道aggregate中的事件是不被外部Listener所共享的?这又是为何 ...


axon的事件可能要和vertx这个eventbus结合。另外一种可能是它的聚合根与其他聚合根之间是通过ID值引用(不能直接相互引用)。

supernavy
2013-12-24 22:07

Repository needs an event bus configured and all events generated by aggregate will be published to the event bus. As long as you listener subscribes to the event bus and matches the event type, it will receive the event.