Forcing the completion of an activity

Why and when to perform this task

Activities in long-running processes can sometimes encounter faults. If these faults are not caught by a fault handler in the enclosing scope and 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. In this state, you can force the completion of the activity.

You can also force the completion of activities in the running state if, for example, an activity is not responding.

Additional requirements exist for certain types of activities.
Staff activities
You can pass parameters in the force-complete call, such as the message that should have been sent or the fault that should have been raised.
Script activities
You cannot pass parameters in the force-complete call. However, you must set the variables that need to be repaired.
Invoke activities
You can also force the completion of invoke activities that call an asynchronous service that is not a subprocess if these activities are in the running state. You might want to do this, for example, if the asynchronous service is called and it does not respond.

Steps for this task

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

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

  2. Complete the activity, for example, a stopped staff activity.

    In this example, an output message is passed.

    if (result.size() > 0)
    {
      	result.first();
    	  AIID aiid = (AIID) result.getOID(1);
    	  ActivityInstanceData activity = process.getActivityInstance(aiid);
      ClientObjectWrapper output = 
            process.createMessage(aiid, activity.getOutputMessageTypeName());
      DataObject myMessage = null;
      if ( output.getObject()!= null && output.getObject() instanceof DataObject )
       {
         myMessage = (DataObject)output.getObject();
         //set the parts in your message, for example, an order number
         myMessage.setInt("OrderNo", 4711);
       }
    
       boolean continueOnError = true;
       process.forceComplete(aiid, output, continueOnError);
    }

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

    In the example, continueOnError is true. This value means that if an error occurs during processing of the forceComplete 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.


Terms of use | | Broken links

Last updated: Tue Dec 06 04:14:41 2005

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