0 Replies Latest reply on Dec 9, 2005 8:41 AM by Andy Morris

    Workflow design advice sought

    Andy Morris Newbie

      I have the following process definition:

      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jbpm.org/3/jpdl" xmlns:xs="http://www.w3.org/2001/XMLSchema"
       <start-state name="start">
       <transition to="poll" />
       <state name="poll">
       <transition to="poll" />
       <transition name="time-out" to="checkeventsubs" />
       <timer name="batchtimer" duedate="30 seconds" transition="time-out" />
       <decision name="checkeventsubs">
       <handler class="com.andy.jbpm.handler.shelflife.CheckForExpiredKnowledgeItems"></handler>
       <transition name="fwd" to="createtasks"></transition>
       <transition name="back" to="poll"></transition>
       <task-node create-tasks="false" name="createtasks">
       <event type="node-enter">
       <action class="com.andy.jbpm.handler.shelflife.CreatePooledTask"></action>
       <task name="revalidation">
       <variable name="knowledgeitemID"></variable>
       <transition name="fwd" to="checkeventsubs" />
       <end-state name='end' />

      The problem I am facing is one of how to model a workflow which is driven by a system event - as opposed to an event initiated by an actor.

      I want a workflow process which will poll my "knowledge items" table every 30 seconds (this is achieved in the "CheckForExpiredKnowledgeItems" DecisionHandler).

      My question really is about how to manage variable passing.
      Effectively my CheckForExpiredKnowledgeItems will pass execution to the createtasks node if it finds an expired KnowledgeItem.

      I am currently passing the item in question to the CreatePooledTask - by adding the javabean to the executionContext as a variable and reading this within the CreatePooledTask handler. This seems a little clunky however. Is there any better way of doing this, making this variable passing more explicit in the workflow itself?

      The CreatePooledTask ActionHandler will read this javabean off the request and create a task instance for it, setting the value of knowledgeItemID on the taskinstance - and setting a number of pooledActorIds.

      Does this sound sensible?

      One other thing that has been niggling me is the issue over these type of long running workflows. Essentially, this workflow will never terminate, as once it's created tasks I want the workflow to continue to poll for new items. Is this dangerous? Am I manipulating the workflow engine to work in a way in which it wasn't designed?

      Many thanks for any guidance.