François-Xavier Seheut de Ronchi [
https://community.jboss.org/people/effixs] created the
discussion
"Sharing jbpmContext with two different threads on jBPM3"
To view the discussion, visit:
https://community.jboss.org/message/803273#803273
--------------------------------------------------------------
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.
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/803273#803273]
Start a new discussion in jBPM Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]