Handling events in multiple threads with Disruptor

418 views
Skip to first unread message

dan.m...@gmail.com

unread,
Oct 19, 2017, 10:38:53 AM10/19/17
to Disruptor
hi, we want to handle events of the same type with a parallel consumer and we do it this way


Disruptor<SomeEvent> disruptor = new Disruptor<>(new AsyncPersistenceMessageEventFactory(), 
                                                                                   4096, threadFactory(), ProducerType.SINGLE, new YieldingWaitStrategy());
 disruptor.handleEventsWithWorkerPool(ourHandler, ourHandler, ourHandler)
        .then((event, sequence, endOfBatch) ->
            event.clear()
         );

Basically, we want every event to be handled once and by one of the three threads (i.e. three ourHandler).

ourHandler is just like this with no logic to do partition and ignore other events etc.

@Override
    public void onEvent(SomeEventevent) throws Exception {

        //some logic

    }

 Is this a correct way to handle what we want?

Michael Barker

unread,
Apr 27, 2018, 3:24:54 AM4/27/18
to lmax-di...@googlegroups.com
Hi,

The set up that you have will result in all three handlers seeing the same event.  The Disruptor is a multicast structure by design.

Mike.

--
You received this message because you are subscribed to the Google Groups "Disruptor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmax-disruptor+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages