I want to handle different event with multi-EventHandleGroup?I can't find example with that.thanks... it's the code:
executorService = Executors.newFixedThreadPool(threadPoolSize);
disruptor = new Disruptor<>(new DefaultEventFactory(),
ringBufferSize, executorService
, ProducerType.SINGLE, new BlockingWaitStrategy());
EventHandlerGroup<OrderEvent> orderEventEventHandlerGroup =
disruptor.handleEventsWith(
new OrderEventHandle(rabbitTemplate));
orderEventEventHandlerGroup.then(new
MoveEventFromProcessing(redisService))
.then(new EventClearHandle());
I want to add another event and I want to handle it with another EventHandleGroup like:
cancelEventDisruptor.handleEventsWith(new
CancelOrderHandle()).then(new MoveEventFromProcessing(redisService))
.then(new EventClearHandle());
All
eventHandlerssee all messages. To achieve what you are looking for yourOrderEventHandleandCancelOrderHandleneed to be able to establish the type of event seen and ignore the ones which do not apply to them.In the example code you are also setting up two complete handling chains. You would be better advised to have a single
MoveEventFromProcessinggated (see SequenceBarrier) on both theOrderEventHandleandCancelOrderHandleand then gate theEventClearHandleon that. So the topology would look likeProducer -> RB -> OrderEventHandle -> MoveEventFromProcessing -> EventClearHandle \-> CancelEventHandle /