1) What is the trigger to have it reviewed again? Maybe you can retrieve it based on a business key and get only running instances. Or that might be an extension to jBPM
2) You can from the console. Look at what code is behind that to get an impression on how to do it.
1) The trigger is someone coming into the app and saying they want to review it again. My design currently lets the process go to the end state once the review has been done. I'm not sure if I can (or how) move a process from the end state back to the start. And I don't like the idea of leaving the process open just incase a review needs to be done again. So was wondering how best to achieve this.
2) Ok, I haven't installed the console... I'll have a look at this... you say you can delete them off in there.
If someone could post the API to remove a process instance that would help me a lot. I'm using jboss seam and so installing the console is going to take me a while I think (the jbpm jars are included with seam etc).
So I call a call like:
ManagedJbpmContext.instance().removeProcess("my process name")
you don't have to install the console, just look at the source of it... you'll get an idea there, or look at the api docs. Might be something in there to.
This raises a point I could use some clarification on.
We ended up removing the unique constraint:
unique (KEY_, PROCESSDEFINITION_)
from the JBPM_PROCESSINSTANCE table because it was causing a key violation when we started multiple processes using:
We don't understand why we had to do that.
If the key must be unique, I would expect to see the key as a parameter in "newProcessInstance(..)" -- in fact, how do you even set the key?!
But in answer to tom_goring's question, he could do what we did, remove the unique constraint, then get the ProcessInstance with the highest version number for that key (or maybe there is another field that indicates that a process is not ended).
I'd like to learn more how this "KEY" is intended to be used, set, etc.
Forgot to mention: our database is Oracle.
Yes this was the problem I had with mysql... the constraint failed.
So it looks like your approach is to start a new process (with the same key).
I think this would work for me provided I could tell which processes (if there were several) were at their end state.