3 Replies Latest reply on Sep 11, 2012 9:37 PM by Steven Hawkins

    ReusableExecution Lifecycle during Continuous execution

    Andriy Rokhmanov Newbie



      I think I am not completely sure about how ReusableExecution react on DataNotAvailableException.


      My translator periodically returns one row of data with a small delay between executions. This is the regular flow of translator method calls during continuous execution which I see in logs:

      1. execute()

      2. next() // I throw DataNotAvailableException(10000) here because my "row" is not ready, so execution goes to sleep.

      3. next() // after 10 seconds execution continue, method next() returns the row which was not ready 10 seconds ago, then returns null;

      4. close();

      5. reset();

      6. execute(); // the next round of continuous execution, repeat after step 1  ( next() throw another exception to wait for 10 seconds, etc.).


      Everything good.

      Now I want to try a different approach. I want to throw DataNotAvailableException.NO_POLLING, and then use executionContext.dataAvailable() to "wake up" translator at some point. My goal - do not wait full 10 seconds if row is availlable earlier.


      Here is what I see:

      1. execute()

      2. next() // I throw DataNotAvailableException.NO_POLLING;

      3. onMessage() // this is my custom method, which has the executionContext.dataAvailable() and gets called when the row is ready (can be 1 second delay, can be 100, does not matter);

      4. next() // translator wakes up, method returns the row, then returns null;

      5. close()

      6. reset()

      7. execute() // now the most interesting. After this step we repeat from step 1 - another DataNotAvailableException.NO_POLLING thrown in the next() method. This time the execution locks completely, and dataAvailable() from step 3 has no effect.

      I tried NO_POLLING with and without "strict" option, or as variant a DataNotAvailableException(new Date(from far-far future)) - the same lethargic behavior, I can not wake up translator - the next() method is not executed this time.


      Does it mean I can use DataNotAvailableException.NO_POLLING only once per execution, or I overlooked something in my approach?