Hello everynone. My first post. I think I read every post about the jBpmContext and nothing gave me the solution...
I'm using jBPM 3 with SEAM. I launch an asynchronous event which launches a ProcessInstance.
I am using another asynchronous event to cancel the previously launched ProcessInstance.
@Observer("builderObserver")
public void startProcessForBuilder(final PackageConfiguration packageConfiguration, final Package pack) {
try {
final JbpmConfiguration jbpmConfig = JbpmConfiguration.getInstance();
final JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
final GraphSession graphJbpm = jbpmContext.getGraphSession();
final ProcessDefinition processDef = graphJbpm.findLatestProcessDefinition("builder");
final ProcessInstance processInstance = processDef.createProcessInstance();
processInstance.getContextInstance().setVariable("packageConfigurationId", packageConfiguration.getId());
jbpmContext.save(processInstance);
pack.setJbpmProcessId(processInstance.getId());
processInstance.getContextInstance().setVariable("packLauncher", pack);
....
@Observer("cancelBuilderObserver")
public void cancelProcessForBuilder(final Package pack) {
try {
final JbpmConfiguration jbpmConfig = JbpmConfiguration.getInstance();
final JbpmContext jbpmContext = jbpmConfig.getCurrentJbpmContext();
final GraphSession graphJbpm = jbpmContext.getGraphSession();
final ProcessDefinition processDef = graphJbpm.findLatestProcessDefinition("builder");
final ProcessInstance processInstance = graphJbpm.getProcessInstance(processDef.getId());
...
But when I do jbpmConfig.getCurrentJbpmContext(); the value is null. It is probably due to different transactions.
I just want to be able to end a processInstance using its id.
Could you please help me?
Thanks.