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"
       xsi:noNamespaceSchemaLocation="file:/C:/jbpm-starters-kit-3.0.1/jbpm/src/java.jbpm/org/jbpm/jpdl/xml/jpdl-3.0.xsd"
       name="SYS_SHELFLIFE_CHECKER">
      
       <start-state name="start">
       <transition to="poll" />
       </start-state>
      
       <state name="poll">
       <transition to="poll" />
       <transition name="time-out" to="checkeventsubs" />
       <timer name="batchtimer" duedate="30 seconds" transition="time-out" />
       </state>
      
       <decision name="checkeventsubs">
       <handler class="com.andy.jbpm.handler.shelflife.CheckForExpiredKnowledgeItems"></handler>
       <transition name="fwd" to="createtasks"></transition>
       <transition name="back" to="poll"></transition>
       </decision>
      
       <task-node create-tasks="false" name="createtasks">
       <event type="node-enter">
       <action class="com.andy.jbpm.handler.shelflife.CreatePooledTask"></action>
       </event>
       <task name="revalidation">
       <controller>
       <variable name="knowledgeitemID"></variable>
       </controller>
       </task>
       <transition name="fwd" to="checkeventsubs" />
       </state>
      
       <end-state name='end' />
      </process-definition>
      


      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.

      Cheers,

      Andy