I have a need to implement a workflow for an application which checks a database value periodically and then invokes a relevant workflow to handle the state.
I can think of a couple of obvious ways of doing this:
1. Have a dedicated Thread which polls and determines when to fire a specific workflow.
2. Integrate this polling mechanism into the workflow design using a timer which is fired periodically. This would in turn execute an ActionHandler which would perform the database state check.
The main drawback with option 1 is that it isn't a unified approach to handling this types of workflow. If I need a new polling mechanism in the future, I will have to write a dedicated class.
Option 2 is promising, however, how dangerous is it to implement a polling mechanism in a workflow which effectively never ends?
All comments gratefully received,
From the description you give I would go for a mechanism based on a real scheduler such as Quartz. Your second option is not very robust as it depends on a thread that is launched from the default jBPM webapp. Or you would have to implement a scheduling mechanism based on the timer service available in your favorite application server.