3 Replies Latest reply on Nov 18, 2005 4:05 PM by aparna.krishna

    Looping after signal

    weliwarmer

      Hi,

      I have a process containing states that send JMS messages and wait for JMS replies before signalling. Once the reply is received in the listener thread, the ExecutionConext for the ActionHandler is stale and the db session is closed. I reload the ProcessInstance and signal but the process loops back the beginning of the same task.

      A snip of the process definition is

      <state name="Remote Job 1">
       <event type="node-enter">
       <action class='actions.RemoteJobHandler'>
       <command>remoteJob1 a b c</command>
       </action>
       </event>
       <transition name="next" to="Remote Job 2"></transition>
      </state>
      <state name="Remote Job 2">
       <event type="node-enter">
       <action class='actions.RemoteJobHandler'>
       <command>remoteJob2 a b c</command>
       </action>
       </event>
       <transition name="next" to="Remote Job 3"></transition>
      </state>


      The code used to signal, which is run from the onMessage of the JMS listener...
      public void signal( ExecutionContext executionContext )
      {
       ContextBuilder contextBuilder = ContextBuilder.create( "pojo" );
       try
       {
       contextBuilder.begin();
       GraphSession graphSession = JbpmSessionContext.getGraphSession();
       ProcessInstance processInstance = graphSession.loadProcessInstance( executionContext.getProcessInstance().getId() );
      
       Token token = processInstance.getRootToken();
       if ( logger.isDebugEnabled() )
       logger.debug( "signaling from node " + token.getNode().getName() );
      
       token.signal();
      
       if ( logger.isDebugEnabled() )
       logger.debug( "signaling moved us to " + token.getNode().getName() );
       }
       finally
       {
       contextBuilder.end();
       }
      }


      This code just loops round "Remote Job 1" until I kill it. There's no splits so signaling on the root token I think should be OK.

      I've upgraded to the latest CVS (19th Sep 2005) and moved from the deprecated JbpmSessionFactory to the ContextBuilder stuff with the hope of a solution but not joy.

      Anyone know how to fix my signal?

      Thanks,
      Tim

        • 1. Re: Looping after signal
          icyjamie

          Don't you have to implement the "execute" method in the actionHandler in stead?

          • 2. Re: Looping after signal
            weliwarmer

            Sorry I was not clear..... yep, the execute method sends off a JMS message and starts a listener thread that waits for a reply. On a reply, I've tried executeContext.signal() but that just gives a lazy initialisation error because the session has been close. The next thing was to try reloading in a new session but that just loops round the same state over-and-over.

            Ta, Tim

            • 3. Re: Looping after signal
              aparna.krishna

              Hi

              How did you implement the RemoteJobHandler? I need to execute some actions remotely(on a different machine), and am looking for ways to implement in JBPM.

              Thanks a lot,
              Aparna