JBoss Community

Re: How to make a process instance go on with jBPM5?

created by Sebastien Lelarge in jBPM - View the full discussion

Thank you for your answer Melih. I've tried this yesterday but it caused bad results and Transaction related exceptions when I tried to completeWorkItem from the method where I call the complete command with the TaskCient.

 

hopefully, I have just found the reason why my process instances refused to go on after session restore and I will share this below.

Now things seems to be going well after restarts

 

It is possible that some users are in the same situation.

In mine, the jBPM engine is embedded in a web application and the Human Task server is started from a dedicated servlet (as suggested by bpmn2user in another post) that launches it as a separate thread.

On the other side, the jBPM engine is initialized (knowledge base and session creation) at application startup in a ServletContextListener.

 

What I didn't realize at this time is that the Human Task server is not yet started when I register the "Human Task" worktitem with the ksession...

It seems (but I am not sure) that the register command tries to contact the HT server but logs nothing whatever connection result.

In the case where the HT server is not available, then the WorkItemHandler cannot wake up the persisted workitems correctly. Particularly, when I tried to complete a task, the Task Server returned a "No listeners found" message telling that it didn't have signals to send back to the workflow engine.

 

Now that I know that, I have rewritten my HumanTask Server servlet in order to proceed to WorkItem registration after the server is correctly started.

And things are working without manually completing workItem when completing tasks

 

Here is a snippet of my start HT server servlet

logger.info("Starting jBPM Human Task Server...");
        taskServerDaemon.startServer(this.port);
        logger.info("jBPM Human Task Server started.");
        
        // Get the Knowledge Session initialized at application startup from app context
        // and register Human Task WorkItem
        logger.info("Registering Human Task Service for jBPM session.");
        StatefulKnowledgeSession ksession = (StatefulKnowledgeSession)this.getServletContext().getAttribute(ksessionAttribute);
        if (ksession == null) {
            logger.error("The retrieved ksession is null. Cannot continue");
        } else {
            CommandBasedWSHumanTaskHandler wsht = new CommandBasedWSHumanTaskHandler(ksession);
            
            try {
                hostname = InetAddress.getLocalHost().getHostName();
            } catch (UnknownHostException uhe) {
                logger.error("Unable to resolve local host IP");
            }
            wsht.setConnection(this.hostname, this.port);
            wsht.connect();
            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", wsht);
            logger.info("Human Task Service for jBPM session " + ksession.getId() + " is registered");
        }

 

I hope this can help

Reply to this message by going to Community

Start a new discussion in jBPM at Community