getting jBPM to save state at all times
sforema Dec 2, 2005 4:04 PMI would like jBPM to save its state in the database as anything changes (new node entered/left/etc). I've tried turning on autocommit both in hibernate and in the code by getting the connection and turning autocommit on, but it doesn't seem to work.
The persistence doc does explain how to resolve this:
http://docs.jboss.com/jbpm/v3/userguide/persistence.html
The only way I've been able to save data to the database is by starting a transaction and eventually committing it. I don't think I should have to manage this. If there is parallel processing going on, this would get nightmarish.
I noticed this problem when I started running a query to check the status of the process as it was running to find that NOTHING was in the database because the commit was after the initial signal.
code snippet:
// start transaction
jbpmSession.beginTransaction();
// run entire process
// > if this runs for an hour, I can't see what is going on
rootToken.signal();
// commit entire process (yuck!)
jbpmSession.commitTransaction();
meanwhile, the entire process (n signals) has run within the initial signal and I can't monitor it from the database because nothing will go into it until the commit. If the VM would go down in the middle of the transaction, things could get even worse because I don't know what was done and what wasn't.
Even if I wanted to manage this within each node, I don't think I can get a handle to the transaction (and I wouldn't want to because two asynch threads could do bad things to the transaction out of order: thread 1 commits, thread 2 tries to commit before thread 1 can begin a new transaction)
Status query for reference:
select
def.id_ as def_id,
def.name_ as def_name,
def.version_ as def_version,
instance.id_ as instance_id,
instance.start_ as instance_start,
instance.end_ as instance_end,
token.id_ as token_id,
token.nodeenter_ as token_enter,
node.id_ as node_id,
node.name_ as node_name,
node.class_ as name_class,
var.name_ as var_name,
var.stringvalue_ as var_value
from
jbpm_processinstance instance,
jbpm_processdefinition def,
jbpm_token token
left outer join jbpm_variableinstance var
on token.id_ = var.token_,
jbpm_node node
where
instance.end_ is null
and instance.processdefinition_ = def.id_
and instance.roottoken_ = token.id_
and token.node_ = node.id_