0 Replies Latest reply on Nov 2, 2005 6:45 AM by abhikal

    how to implement schedular

    abhikal

      hi

      please help to know that did i missed anything while programming the timers

      the process have 3 states
      1. start state
      2. state2
      3. end state


      handler class for action is not executing and when the timer duration is over it is not moving to next state. Any Suggestions

      and the code is

      package sc;
      
      
      import java.util.Iterator;
      import java.util.List;
      
      import org.jbpm.db.GraphSession;
      import org.jbpm.db.JbpmSession;
      import org.jbpm.db.JbpmSessionFactory;
      import org.jbpm.db.SchedulerSession;
      import org.jbpm.graph.def.Action;
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.def.Event;
      import org.jbpm.graph.def.Node;
      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ExecutionContext;
      import org.jbpm.graph.exe.ProcessInstance;
      import org.jbpm.graph.exe.Token;
      import org.jbpm.scheduler.exe.Timer;
      import org.jbpm.scheduler.impl.Scheduler;
      
      public class TestSch
      {
       static JbpmSessionFactory jsf=null;
       static
       {
       jsf=JbpmSessionFactory.buildJbpmSessionFactory();
       jsf.getJbpmSchema().createSchema();
       }
       public TestSch()
       {
      
       ProcessDefinition pd = ProcessDefinition.parseXmlString(
       "<process-definition>" +
       " <start-state>" +
       " <transition to='catch crooks' />" +
       " </start-state>" +
       " <state name='catch crooks'>" +
       " <timer name='reminder'" +
       " duedate='1 minutes'" +
       " transition='end' >" +
       " <action class='sc.action2' />" +
       " </timer>" +
       " </state>" +
       " <end-state name='end'/>" +
       "</process-definition>"
       );
       JbpmSession js = jsf.openJbpmSession();
       SchedulerSession ss=new SchedulerSession(js);
       js.beginTransaction();
      
       ProcessInstance pi = new ProcessInstance(pd);
      
       pi.signal();
      
       js.getGraphSession().saveProcessDefinition(pd);
       js.getGraphSession().saveProcessInstance(pi);
      
      
       js.getGraphSession().loadProcessInstance(pi.getId());
       Timer timer = (Timer) ss.findTimersByDueDate().next();
       js.getSchedulerSession().saveTimer(timer);
       js.getGraphSession().saveProcessInstance(pi);
       js.commitTransaction();
      
       ss=js.getCurrentJbpmSession().getSchedulerSession();
       System.out.println(pi.getRootToken().getNode().getName());
      
      }
       public static void main(String[] args)
       {
      
       TestSch tt=new TestSch();
      
      
       }
      
      }
      
      
      
      
      
      
      



      thanks and regard