IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Developing client applications for BPEL processes and tasks > Developing EJB client applications > Developing applications for BPEL processes > Repairing activities

Retrying the execution of a stopped activity

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 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.


Procedure

  1. List the stopped activities.
    FilterOptions fo = new FilterOptions();
    fo.setSelectedAttributes("AIID");
    fo.setQueryCondition("STATE=STATE_STOPPED AND NAME='CustomOrder'");
    EntityResultSet result = process.queryEntities("ACTIVITY", fo, null, null);

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

  2. Retry the execution of the activity, for example, a stopped human task activity.
    if (result.getEntities().size() > 0)
    {
      Entity activityEntity = (Entity) result.getEntities().get(0);
      AIID aiid = (AIID) activityEntity.getAttributeValue("AIID");
      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 a fault handler on the process level is run before the process state ends in the failed state.

Repairing activities


Related concepts:
Continue-on-error behavior of BPEL processes and activities