-1

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());
刘德华
  • 1
  • 1
  • 1
    Please add more details to your question. – AsthaUndefined Nov 19 '18 at 07:02
  • Hi and welcome to SO. Please edit the question to show what you've tried. Like this we will be able to better understand your problem/question and thus we will be able to better help you. It is best to provide a [MCVE]. For more information, please see [Ask] and take the [Tour]. – quant Nov 19 '18 at 07:14
  • I have update it.thanks – 刘德华 Nov 19 '18 at 07:58

1 Answers1

0

All eventHandlers see all messages. To achieve what you are looking for your OrderEventHandle and CancelOrderHandle need 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 MoveEventFromProcessing gated (see SequenceBarrier) on both the OrderEventHandle and CancelOrderHandle and then gate the EventClearHandle on that. So the topology would look like

Producer -> RB -> OrderEventHandle -> MoveEventFromProcessing -> EventClearHandle \-> CancelEventHandle /