Search code examples
javadisruptor-patternlmax

disruptor one event handler stalls other event handlers


I am running a disruptor instance with following event handler:

int NUM_EVENT_PROCESSORS = 5;

executor = Executors.newFixedThreadPool(NUM_EVENT_PROCESSORS);

EventFactory factory = new EventFactory();

System.out.println("Starting Disruptor");

disruptor = new Disruptor<>(factory, RING_SIZE, executor, ProducerType.SINGLE, new BlockingWaitStrategy());
disruptor.handleEventsWith(new Logger(), new Replicator(), new Logic());
disruptor.start();

I have discovered an instance where the Replicator() thread hung and it blocked the Logic() thread.

If there is 1 event in the ringbuffer, do the disruptor threads work sequentially?


Solution

  • Ok this was my own error. I run 2 sets of disruptors (one for client side and one for provider side) and my client side code was the following:

    disruptor.handleEventsWith(new Logger(), new Replicator()).then(new Logic());
    

    while my provider side code was the following:

    disruptor.handleEventsWith(new Logger(), new Replicator(), new Logic());
    

    so the disruptor instance on the client side was doing as it was told. If the replicator blocks so does the logic thread.

    Thanks stack overflow for making me check my code over again.