LMAX Disruptor Timeout EventHandler

545 Views Asked by At

We have a system using Disruptor framework, it has five registered stages implementing EvenetHandler.

The stages work in Sequence, so a request can only move to second stage when the first stage is completed, this movement is maintained by Disruptor internally.

We have problem with the third stage, it's the bottleneck which takes lot of time as it makes different HTTP calls and stores response in the request object.

So, we want to move the request(with whatever response it has) ahead with the fourth and fifth stage after some time has been spend in the third stage.

How can i timeout any specific stage(in this case Third stage) and forcefully move the request to the next stage ?

Or,

Is there a way to register some event which gets triggered after some defined timeout, this could be something like system level timeout ?

1

There are 1 best solutions below

1
On

A solution we tried is

  1. Have a hang detection thread which monitors the sequences processed by a stage ( or all the stages). Have a timing information in the Event processor itself.
  2. On time out interrupt the event processor thread. Which should make the event processor exit from the spin it is doing. So here we lost the thread ( or one of the threads ) processing the stage
  3. Replace the event processor thread.

Solution needs writing our own event processor which is interrupt aware and a provision to add event stages dynamically to the disruptor