Process

Note: the syntax used in these scripts requires wlshell version 2.0.2 or latter.

Set Default Tracking Level

# The following script sets the system wide default tracking level
# for processes

# this script has been tested with WLI 8.1SP2

cd /BPMConfiguration/BPMConfiguration
get DefaultProcessTrackingLevel
level = $LAST
level = $level toTrackingLevel "Minimum"
set DefaultProcessTrackingLevel $level

invoke $savedom $DOMAIN

# the list of available levels is in the VALUES field
print "available levels are: " ${level.VALUES}

# valid levels are: None, Minimum, Node, Full and Default
        

Monitor Process Instances

# The following script monitors all instances of a particular process

# the URI of the process,
# to search for available process URIs, see the /ProcessConfiguration directory
# in wlshell
uri = /processAppWeb/processes/process.jpd

# create and configure the query
query = new com.bea.wli.management.runtime.ProcessInstanceQuery
$query setServiceURI $uri

# run the query
cd /ProcessRuntime/ProcessRuntime
result = invoke getProcessInstances $query

# get instance IDs
ids = $result getInstanceIds

# get instance details
for $id in $ids
  inf = invoke getProcessInstanceInfo $id true
  $inf getId
  $inf getDisplayName
  $inf getServiceURI
  $inf getStatus
  $inf getStartTime
  $inf getExecTime
  $inf getLastStatusChangeTime
end
        

Terminate Running Process Instances

# The following script terminates all running instances of a particular process

# the URI of the process,
# to search for available process URIs, see the /ProcessConfiguration directory
# in wlshell
uri = /processAppWeb/processes/stuckprocess.jpd

# create and configure the query
query = new com.bea.wli.management.runtime.ProcessInstanceQuery
$query setServiceURI $uri

# run the query
cd /ProcessRuntime/ProcessRuntime
result = invoke getProcessInstances $query

# get instance IDs
ids = $result getInstanceIds

# get instance details
for $id in $ids
  inf = invoke getProcessInstanceInfo $id true

  # get status
  status = $inf getStatus

  # get status string
  status = $status toString

  if ($status == "Running")
    pid = $inf getId
    print "process " $pid " is running"
    invoke terminate $uri $pid

    #check again the status
    inf = invoke getProcessInstanceInfo $id true
    $inf getStatus
  end
end