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

Update correlation sets associated with stopped activities

Correlation sets are used to support stateful collaboration between web services. In such cases, the correct values for the expression can be supplied using the Business Process Choreographer EJB API so that the navigation of the process can continue.

An activity that is in a stopped state can require an update of its associated correlation set for one of the following reasons:

You can retrieve the correlation set instances of a process or activity instance. The following example shows how to initialize or unitialize correlation set instances.


Procedure

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

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

  2. Retrieve the correlation set instances that are defined for the activity.
    AIID aiid = null;
    
    List correlationSet = null;
    
    if (result.getEntities().size() > 0)
    {
       Entity activityEntity = (Entity) result.getEntities().get(0);
       AIID aiid = (AIID) activityEntity.getAttributeValue("AIID");
    	  ActivityInstanceData activity = process.getActivityInstance(aiid);
       correlationSet = process.getCorrelationSetInstances
                        (aiid, activity.getInputMessageTypeName());  }
  3. Unitialize the correlation set, for example, MyCorrelationSet.
    for ( int i=0; i<correlationSet.size(); i++ )
    {
      CorrelationSetInstanceData correlationSetInstance = 
                (CorrelationSetInstanceData)correlationSet.get(i);
      
      if ( correlationSetInstance.isInitialized() && 
           correlationSetInstance.getCorrelationSetName().equals("MyCorrelationSet") )
      {
        process.uninitializeCorrelationSet
           ( activity.getProcessInstanceID(), correlSetInstance.getCorrelationSetName() );
      } }
    This action uninitializes the correlation set MyCorrelationSet.

  4. Initialize the correlation set, for example, MyCorrelationSet. In this example, a string-valued property of the correlation set is set.
    for ( int i=0; i<correlationSet.size(); i++ )
    {
      CorrelationSetInstanceData correlationSetInstance = 
                (CorrelationSetInstanceData)correlationSet.get(i);
      
      if ( correlationSetInstance.getCorrelationSetName().equals("MyCorrelationSet") )
      {
        List correlationSetProperties = 
                        correlationSetInstance.getCorrelationSetProperties();
        for ( int j=0; j<correlationSetProperties.size(); j++ )    {
          CorrelationPropertyInstanceData property = 
                    (CorrelationPropertyInstanceData)correlationSetProperties.get(j);
      
          if ( property.getPropertyName().equals("MyProperty") )
          {
            property.setValue("NewValue");
    
            process.initializeCorrelationSet
               ( activity.getProcessInstanceID(), correlationSetInstance );
          }     }   } }
    This action initializes the string-valued property MyProperty in the correlation set MyCorrelationSet.

Repairing activities


Related concepts:
Correlation sets