IBM BPM, V8.0.1, All platforms > Administer the IT infrastructure > Administer Business Process Choreographer > Use scripts to administer Business Process Choreographer > Delete Business Process Choreographer objects

Delete completed task instances

Use an administrative script to selectively delete from the Business Process Choreographer database or Business Process Archive database any top-level task instances that have reached an end state of finished, terminated, expired, or failed.

The following conditions must be met:

A top-level task instance is considered completed if it is in one of the following end states: finished, terminated, expired, or failed. You specify criteria to selectively delete top-level task instances and all their associated data , such as instance custom properties, escalation instances, subtask instances, and follow-on task instances, from the database.

Sometimes follow-on task instances form a chain of follow-on tasks; where all but the last task instance are in the forwarded state and the last task instance in the chain is in some other state. In this case, a top-level task instance that is in the forwarded state is considered to be completed if the last task instance in the chain is in one of the following end states: finished, terminated, expired, or failed.

Normally, an inline task instance is not considered to be a top-level task instance, and cannot be deleted using the deleteCompletedTaskInstances.py script because the inline task instance belongs to a BPEL process, which means use deleteCompletedProcessInstances.py to delete the completed process instance that the inline task belongs to. However, any inline invocation task instance that was created using the Human Task Manager API or the Service Component Architecture (SCA) API is treated as a top-level task instance, and can be deleted using the deleteCompletedTaskInstances.py script.


Procedure

  1. Change to the Business Process Choreographer subdirectory where the administrative script is located.
    cd  INSTALL_ROOT/ProcessChoreographer/admin

    cd INSTALL_ROOT/ProcessChoreographer/admin

    cd INSTALL_ROOT\ProcessChoreographer\admin

  2. Delete task instances from the database.

    •  INSTALL_ROOT/bin/wsadmin.sh  –f deleteCompletedTaskInstances.py 
           (([-node  nodeName] -server  serverName) | (-cluster  clusterName))
           (-all | [-finished] [-terminated] [-failed] [-expired] )
           [-templateName  templateName -nameSpace  nameSpace 
           [-validFromUTC  timestamp]]
           [-createdBy  userID ]
           [(-completedAfterLocal  timeStamp)|(-completedAfterUTC  timeStamp)]
           [(-completedBeforeLocal  timeStamp)|(-completedBeforeUTC  timeStamp)]
    •  INSTALL_ROOT/bin/wsadmin.sh  –f deleteCompletedTaskInstances.py 
           (([-node  nodeName] -server  serverName) | (-cluster  clusterName))
           (-all | [-finished] [-terminated] [-failed] [-expired] )
           [-templateName  templateName -nameSpace  nameSpace 
           [-validFromUTC  timestamp]]
           [-createdBy  userID ]
           [(-completedAfterLocal  timeStamp)|(-completedAfterUTC  timeStamp)]
           [(-completedBeforeLocal  timeStamp)|(-completedBeforeUTC  timeStamp)]
    •  INSTALL_ROOT\bin\wsadmin –f deleteCompletedTaskInstances.py 
          (([-node  nodeName] -server  serverName) | (-cluster  clusterName))
          (-all | [-finished] [-terminated] [-failed] [-expired] )
          [-templateName  templateName -nameSpace  nameSpace 
          [-validFromUTC  timestamp]]
          [-createdBy  userID ]
          [(-completedAfterLocal  timeStamp)|(-completedAfterUTC  timeStamp)]
          [(-completedBeforeLocal  timeStamp)|(-completedBeforeUTC  timeStamp)]

    Where:

    -node nodeName

    The name of the node where Business Process Choreographer is configured. This is optional when specifying the server name. The default is the local node.

    -server serverName

    The name of the server where Business Process Choreographer or Business Process Archive Manager is configured. Required if the cluster name is not specified.

    -cluster clusterName

    The name of the cluster is required if Business Process Choreographer or Business Process Archive Manager is configured on a cluster. You can either specify the cluster name or the server name and node name.

    -all | [-finished] [-terminated] [-failed] [-expired]

    Specifies which task instances are to be deleted according to their state. The -all option means all end states: finished, terminated, failed, and expired. If you do not specify -all, you must specify one or more of the end states.

    -templateName templateName

    Optionally, specifies the name of the task template whose instances will be deleted. If you specify this option you must also specify the nameSpace parameter. If there are multiple task templates sharing the same name but with different validFromUTC dates the instances for all task templates with that name are deleted unless you use the validFromUTC parameter to specify a particular template.

    -nameSpace nameSpace

    Optionally, specifies the namespace of the task template to be deleted. If you specify this option you must also specify the templateName parameter. If there are multiple task templates sharing the same name but with different validFromUTC dates the instances for all task templates with that name are deleted unless you use the validFromUTC parameter to specify a particular template.

    -validFromUTC timestamp

    The date and time from which the template is valid in Coordinated Universal Time (UTC). The string must have the following format: 'yyyy-MM-ddThh:mm:ss' (year, month, day, T, hours, minutes, seconds).

    For example, 2005-01-31T13:40:50

    -createdBy userID

    Optionally, only deletes completed task instances that were created by the given User ID.

    -completedAfterLocal timestamp

    Optionally, specifies that only instances that completed after the given local time on the server are deleted. The format for the timestamp string is the same as for -validFromUTC, except that the time part is optional for this parameter. If you only specify a date, the time defaults to 00:00:00 local time on the server.

    -completedAfterUTC timestamp

    Optionally, specifies that only instances that completed after the given UTC time are deleted. The format for the timestamp string is the same as for -validFromUTC, except that the time part is optional for this parameter. If you only specify a date, the time defaults to 00:00:00 local time on the server.

    -completedBeforeLocal timestamp

    Optionally, specifies that only instances that completed before the given local time on the server are deleted. The format for the timestamp string is the same as for -validFromUTC, except that the time part is optional for this parameter. If you only specify a date, the time defaults to 00:00:00 local time on the server.

    -completedBeforeUTC timestamp

    Optionally, specifies that only instances that completed before the given UTC time are deleted. The format for the timestamp string is the same as for -validFromUTC, except that the time part is optional for this parameter. If you only specify a date, the time defaults to 00:00:00 local time on the server.

    For example, to delete the task instances on cluster myCluster that are in the finished state, and were created by the user Erich:

    wsadmin.sh –f deleteCompletedTaskInstances.py 
               -node  myNode -server  myServer 
               -finished
               -createdBy Eric

    wsadmin.sh –f deleteCompletedTaskInstances.py 
               -node  myNode -server  myServer 
               -finished
               -createdBy Eric

    wsadmin –f deleteCompletedTaskInstances.py 
            -node  myNode -server  myServer 
            -finished
            -createdBy Eric

    If Business Process Choreographer is configured on the cluster, the tasks will be deleted from the Business Process Choreographer runtime database. If Business Process Archive Manager is configured on the cluster, the same command will delete the specified tasks from the archive database associated with the Business Process Archive Manager. Be careful not to delete any instances from a runtime database that should actually be moved to an archive.

  3. If the script triggers long-running work on the server, the script might fail if the connection timeout is not long enough to complete the action. Check the SystemOut.log file on the server to see whether you need to restart the script. If the timeout happens often, consider increasing the value of the timeout property for the connector you are using, or adjusting the script parameters to reduce the amount of work done on the server.


Results

The completed task instances have been deleted from the database associated with the Business Process Choreographer or Business Process Archive Manager configuration on the given deployment target.

Delete Business Process Choreographer objects


Related concepts:
How time zones are handled in Business Process Choreographer


Related information:

Options for maintaining an optimal Business Process Choreographer database size
Connection timeout when running a wsadmin script