Retrying the execution of a stopped activity

Why and when to perform this task

If an activity in a long-running process encounters an uncaught fault in the enclosing scope and if the associated activity template specifies that the activity stops when an error occurs, the activity is put into the stopped state so that it can be repaired. You can retry the execution of the activity.

You can set variables that are used by the activity. With the exception of script activities, you can also pass parameters in the force-retry call, such as the message that was expected by the activity.

Steps for this task

  1. List the stopped activities.
    QueryResultSet result = 
          process.query("DISTINCT ACTIVITY.AIID",
                        "ACTIVITY.STATE = ACTIVITY.STATE.STATE_STOPPED AND 
                         PROCESS_INSTANCE.NAME='CustomerOrder'",
                         (String)null, (Integer)null, (TimeZone)null);

    This action returns the stopped activities for the CustomerOrder process instance.

  2. Retry the execution of the activity, for example, a stopped staff activity.
    if (result.size() > 0)
    {
      result.first();
      AIID aiid = (AIID) result.getOID(1);
      ActivityInstanceData activity = process.getActivityInstance(aiid);
      ClientObjectWrapper input = 
            process.createMessage(aiid, activity.getOutputMessageTypeName());
      DataObject myMessage = null;
      if ( input.getObject()!= null && input.getObject() instanceof DataObject )
        {
          myMessage = (DataObject)input.getObject();
          //set the strings in your message, for example, chocolate is to be ordered
          myMessage.setString("OrderNo", "chocolate");
        }
    
       boolean continueOnError = true;
       process.forceRetry(aiid, input, continueOnError); 
    }

    This action retries the activity. If an error occurs, the continueOnError parameter determines the action to be taken if an error occurs during processing of the forceRetry request.

    In the example, continueOnError is true. This means that if an error occurs during processing of the forceRetry request, the activity is put into the failed state. The fault is propagated to the enclosing scopes of the activity until it is either handled or the process scope is reached. The process is then put into the failing state and it eventually reaches the failed state.

Related concepts
Queries on business-process and task-related objects

Copyright IBM Corporation 2005, 2006.
This information center is powered by Eclipse technology (http://www.eclipse.org)