15.2. Process Instance

Process instances are persisted as ProcessInstanceInfo entities, which persist the state of a process instance on runtime and store the following data:

FieldDescriptionNullable

instanceid

primary key

false

lastmodificationdate

last saved to data store

N/A

lastreaddate

last read from data store

N/A

processid

ID of the process the instance is based on

false

processinstancebytearray

binary dataset with process instance state (binary blob)

false

startdate

Process instance start date

 

optlock

version number used lock value for optimistic locking

 

state

Process instance state

false

ProcessInstanceInfo has a 1:N relationship to the EventTypes entity.

The EventTypes entity contains the following data:

FieldDescriptionNullable

instanceid

reference to the Process instance (foreign key to the processinstanceinfo)

false

element

text field related to an event the Process instance has undergone

 

Pessimistic Locking Support

The default locking mechanism for persistence of processes is optimistic. With multi-thread high concurrency to the same process instance, this locking strategy can result in bad performance.

With the release of the 6.1 version of Red Hat JBoss BPM Suite, this can be changed at runtime to allow the user to set locking on a per process basis and to allow it to be pessimistic (the change can be made at a per KIE Session level or Runtime Manager level as well and not just at the process level).

To set a process to use pessimistic locking, do this in the runtime environment:

import org.kie.api.runtime.Environment;
import org.kie.api.runtime.EnvironmentName;
import org.kie.api.runtime.manager.RuntimeManager;
import org.kie.api.runtime.manager.RuntimeManagerFactory;

...

// here env is an instance of org.kie.api.runtime.Environment
env.set(EnvironmentName.USE_PESSIMISTIC_LOCKING, true);

// now create your Runtime Manager using this environment
RuntimeManager manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment);