10 Replies Latest reply on Aug 5, 2011 1:41 AM by Maciej Swiderski

    Advice on how to approach CRON based BPMN2 processes

    olddave Newbie

      Hi,

       

      I have the need to run Processes, with no human tasks, on a repeating basis, normally 3 times a day, weekdays and excluding holidays. But I also need to run the same tasks on an ad hoc basis. So if I code a new workitem that is a Start task that uses Quartz scheduler (thus holidays can be supported) I could not run that on an ad hoc basis. Alternately I could use a normal Start task and have a diverging gateway as the first node that tests for a boolean param that represents "run now" it could diverge to a converging gateway and thus to the actual first node that does real work in the Process, the alternate path would hit the new Timer workitem that I would have to code that also used Quartz, this would then hit a converging gateway with the direct run now path to start the actual Process that does the work I need. Another alternative is theh start task with Quartz and also an integrated parameter test for pass through.

       

      Any suggestions on how this problem scenario is best solved?

       

      thx.

       

      Ed

        • 1. Re: Advice on how to approach CRON based BPMN2 processes
          Mare Geldenhuys Newbie

          Hi Ed,

           

          what about adding the job to the Quartz scheduler which kicks of the process? Meaning, the responsibility of the job which executes in Quartz would be to either create a knowledge session or get one from somewhere to start a process. This way the schedules are managed by Quartz but what happens when the job is executed is managed by JBPM. Then you can also call JBPM to run the process on an ad-hoc basis, without having to handle timers that should not fire in the process.

           

          Would that work?

          1 of 1 people found this helpful
          • 2. Re: Advice on how to approach CRON based BPMN2 processes
            olddave Newbie

            That would work, but then I miss out on getting details of processes that are running via the gwt-console, because the activation of them is outside Drools. I am starting to think I need the 3rd option a new Start task that has Quartz and a pass through run now option. That way I can see the Process in the list of running processes and by putting the CRON expression in a variable be able to see that detail as well through the gwt-console.

             

            Ed

            • 3. Re: Advice on how to approach CRON based BPMN2 processes
              Maciej Swiderski Master

              Have you tried to have a start event and a timer event that can start the process? That is valid approach according to BPMN2. I am referring to something similar as is illustrated on the Events section jBPM documentation just instead of message events have a timer event.

               

              So that should do what you describe - time event will fire on every expiration and you can use default start event to start it whenever you like.

               

              Cheers

              Maciej

              • 4. Re: Advice on how to approach CRON based BPMN2 processes
                Mare Geldenhuys Newbie

                Using the timer event would not cater for running the process on a complex schedule, since it only allows having the timer activated after a set amount of time which is specified in the timer nodes parameter, and does not have the flexibility of being specified to not run on public holidays.

                 

                As I understand putting the CRON expresion in a variable means that you will have to implement the interpretation of the expresion in the gateway node or "run now" node to say when the process should execute. Which you could do and then have a timer event which fires every few minutes and feeds into this node. Or have the "run now" node be a rule task which makes a decision based on the current time, but then not use a CRON expression but a DROOLS business rule.

                 

                Another option to implement the functionality using a CRON expression, is to create a second process which manages the creation of scheduled jobs which in turn kick of the actual process you want to execute. The quartz job will have to communicate via some form to the console server (I think it exposes some web services) to run the processes. The main process can then be used to cancel an existing job and its trigger, if one exists and then add a new job and trigger based on the parameter passed though from the node. You will have to look at implementing a domain specific task node for this functionality though.

                 

                Mare

                • 5. Re: Advice on how to approach CRON based BPMN2 processes
                  Maciej Swiderski Master

                  I agree that timer event will not cover all requirements right now, but I think it would be rather clean solution to handle the basic scenario (excluding holidays). To deal with holiday, you could put rule task just after timer and decide if the particular triggered time falls down to a holiday, and if so cancel that process instance.

                  • 7. Re: Advice on how to approach CRON based BPMN2 processes
                    olddave Newbie

                    Hi,

                     

                    So basically you are saying that to start actual work you have 2 stimuli, the Start node directly through the XOR converging gateway and a new work item that is a CRON Timer that produces an internal event that kicks off the process through the XOR converging gateway. So the Start item could have a boolean variable that causes the XOR converging gateway to pass through, otherwise is waits for the event from the CRON Timer.

                     

                    The things not clear to me are:

                    1. When the Process is invoked without the boolean variable to pass through then does the CRON Timer just automatically 'run' to check the CRON schedule to check if an event is due to be produced? My understanding is that a node in the Process does not just 'run', it is invoked when the workflow 'hits' it?

                    2. Once the XOR converging gateway is passed won't the Process continue through to the End node and then finish, thereby leaving no CRON Timer thread to check to see if the next event is due to be produced? I.e. How do we make the Process run permanently? Is this achieved by a loop path in the workflow itself, maybe into that 1st XOR converging gateway where it waits for the event to be produced? If so is that std practice?

                     

                    I attach what I think would work, comments welcome. The Signal event task would be replaced by the CRON Timer event task.
                    exampleCRON.png

                     

                    Thx.

                     

                    Ed

                    • 8. Re: Advice on how to approach CRON based BPMN2 processes
                      Maciej Swiderski Master

                      Ed, I was talking about something like this:

                      multi-events.png

                      timer events should be maintained by the jBPM engine but I am not entirely sure if that is fully supported. Did not have time yet to verify that.

                      That would mean that you specify timer definition and new process instance will be every time the timer expires.

                       

                      Cheers

                      • 9. Re: Advice on how to approach CRON based BPMN2 processes
                        olddave Newbie

                        When I put a Timer task in a workflow it only has 2 useful arguments in the properties sheet, delay and period, no place for a CRON expression. Is there a new Timer type in the development schedule?

                         

                        Thx.

                         

                        Ed

                        • 10. Re: Advice on how to approach CRON based BPMN2 processes
                          Maciej Swiderski Master

                          Most likely it is limitation of eclipse plugin or other tool you use for diagram modeling.

                          Try modify its source xml and use something like this:

                           

                               <timerEventDefinition>
                                  <timeCycle xsi:type="tFormalExpression" language="cron">0/1 * * * * ?</timeCycle>
                                </timerEventDefinition>
                          

                           

                          HTH