[jboss-dev-forums] [jBPM Development] - Sharing jbpmContext with two different threads on jBPM3

François-Xavier Seheut de Ronchi do-not-reply at jboss.com
Mon Mar 18 10:14:12 EDT 2013


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&containerType=14&container=2035]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20130318/9f4d5c84/attachment-0001.html 


More information about the jboss-dev-forums mailing list