10 Replies Latest reply: Sep 17, 2012 8:11 AM by nbd RSS

Signal Event is not happening in persisted process

ravichandrankg Newbie

Hi,

 

In our company, we are doing some sample process implementation for our application, to decide which BPM engine to be use. It mostly have external system communication, that will trigger the next set of activities in our application.

 

I am using the following sample process, with one human task and two script tasks with signal events (to trigger from external applications).

 

Untitled.png

and first signal event is having the properties as below,

 

properties.jpg

 

I am using JBPM 5.3.0.Final version, JBOSS 5.1 and MySQL 5.5.

 

I am creating a single knowledge session for whole my web application (singleton object holder class, initializing at server startup time). I am creating the process as,

 

 

     StatefulKnowledgeSession jbpmsession = util.getSession();

     UserTransaction ut = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );

     ut.begin();

     ProcessInstance instance = jbpmsession.startProcess("IngestMetadataAndFile", props);

     jbpmsession.insert(instance);

     ut.commit();

 

and the getSession method will return the new session for first time, and reloaded session there after, using the following code.

 

    

     StatefulKnowledgeSession sessionobj = null;

     Properties properties = new Properties();

     properties.put("drools.processInstanceManagerFactory", "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

     properties.put("drools.processSignalManagerFactory", "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

     KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);

 

     if (sessionId == -1) {

         sessionobj = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, config, env );

     } else {

                              try {

                                        sessionobj =  JPAKnowledgeService.loadStatefulKnowledgeSession( sessionId, kbase, config, env);

                              } catch(Exception e) {

                                        System.out.println("Exception in loading the session");

                                        sessionobj = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, config, env );

                              }

                    }

 

                    new JPAWorkingMemoryDbLogger(sessionobj);

                    KnowledgeRuntimeLoggerFactory.newConsoleLogger(sessionobj);

                    JPAProcessInstanceDbLog processLog = new JPAProcessInstanceDbLog(sessionobj.getEnvironment());

 

                    DsrClientHandler wsHumanTaskHandler = new DsrClientHandler(sessionobj);

                    wsHumanTaskHandler.setClient(client.getTaskClient());

                    sessionobj.getWorkItemManager().registerWorkItemHandler("Human Task",wsHumanTaskHandler);

        

With this code, i can able to create the process instance successfully and i am completing the human task by using HornetQ service. It is sucessfully completing the human task and coming to the script task (i can see the syslogs in the script task get printed). From the script task, i am calling my business implementation java class and calling signal event after the business logic completion.

 

I am signalling as below,

 

       StatefulKnowledgeSession ksession =  util.getSession();

       ksession.signalEvent(eventtype, null, Long.parseLong(processid));

       //ksession.signalEvent(eventtype, null);

       ProcessInstance processinst = ksession.getProcessInstance(Long.parseLong(processid));

       //processinst.signalEvent(eventtype, null);

 

after this signalling, it is not coming to the next script task. I have developed my BPMN file by using eclipse (setup using JBPM 5.3 installer).

 

I dont know what is really wrong with my code. I am not getting any exception after the signal event, but console is printing the following logs.

 

 

 

2012-07-31 12:29:27,804 INFO  [STDOUT] (Thread-26) BEFORE PROCESS NODE EXITED node:External Task1[id=4] process:Sample new DSR Process[id=IngestMetadataAndFile]

2012-07-31 12:29:27,805 INFO  [STDOUT] (Thread-26) BEFORE PROCESS NODE TRIGGERED node:Signal[id=5] process:Sample new DSR Process[id=IngestMetadataAndFile]

2012-07-31 12:29:27,805 INFO  [STDOUT] (Thread-26) AFTER PROCESS NODE TRIGGERED node:Signal[id=5] process:Sample new DSR Process[id=IngestMetadataAndFile]

2012-07-31 12:29:27,805 INFO  [STDOUT] (Thread-26) AFTER PROCESS NODE TRIGGERED node:External Task1[id=4] process:Sample new DSR Process[id=IngestMetadataAndFile]

2012-07-31 12:29:27,805 INFO  [STDOUT] (Thread-26) AFTER PROCESS NODE TRIGGERED node:External Task1[id=4] process:Sample new DSR Process[id=IngestMetadataAndFile]

2012-07-31 12:29:27,805 INFO  [STDOUT] (Thread-26) AFTER PROCESS NODE TRIGGERED node:EnterMetadata[id=2] process:Sample new DSR Process[id=IngestMetadataAndFile]

 

 

can you please help me to get out of this issue, where i got stucked and invested lot of time .

 

 

Thanks,

Ravichandran

  • 1. Re: Signal Event is not happening in persisted process
    Maciej Swiderski Master

    That sounds weird as there are few test cases in code base that test that, if you could prepare test case that reproduces that and attach it to jira would be create. So we could confirm that this is a bug and if so fix it.

     

    Cheers

  • 2. Re: Signal Event is not happening in persisted process
    ravichandrankg Newbie

    Thanks Maciej for comeback.

     

    I have created a testcase and run it with single session (means not reloaded), it is working fine .

     

    But it is not working in my web application. In my app, i am reloading the session with the sessionid, which persisted seperately.

     

          sessionobj =  JPAKnowledgeService.loadStatefulKnowledgeSession( sessionId, kbase, config, env);

     

    Is there any other way to acheive the correlation in persisted environment. If any clue on my issues, kindly help me out.

     

     

    Thanks,

    Ravichandran


  • 3. Re: Signal Event is not happening in persisted process
    Maciej Swiderski Master

    could you try extending your test case to use persistence and reload the session in between of signals? Take a look at documentation for details about unit testing.

     

    HTH

  • 4. Re: Signal Event is not happening in persisted process
    ravichandrankg Newbie

    Hi Maciej,

     

    Thanks for your reply. i tried the test case with persistence as below.

     

     

    public class DsrTestcase extends JbpmJUnitTestCase {

              public DsrTestcase() {

                        super(true);

              }

     

    public void testProcess() {

                        StatefulKnowledgeSession ksession = createKnowledgeSession("dsrpocNewSig.bpmn");

                        Map<String, Object> params = new HashMap<String, Object>();

                        params.put("actorid", "krisv");

                        ProcessInstance instance = ksession.startProcess("IngestMetadataAndFileSIG", params);

     

                        System.out.println("process created");

                        int id = ksession.getId();

                        ksession.signalEvent("validatewithshowevent", null, instance.getId());

                        loadSession(id, "dsrpocNewSig.bpmn");

                        ksession.signalEvent("qcvideotask", null, instance.getId());

              }

    }

     

     

     

     

    But i am getting the following exceptions while creating the EntityManagerFactory. I have kept the persistence.xml with proper persistence-unit name.

     

    javax.persistence.PersistenceException: No Persistence provider for EntityManager named org.drools.persistence.jpa

              at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:56)

              at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)

     

    can you please provide some sample code for the persistence testing as unit test.

     

     

    Thanks,

    Ravichandran

  • 5. Re: Signal Event is not happening in persisted process
    Maciej Swiderski Master

    this indicates you don't have hibernate on the classpath. add hibernate entity manager and its dependencies and you'll be able to execute it.

     

    HTH

  • 6. Re: Signal Event is not happening in persisted process
    ravichandrankg Newbie

    Hi Maciej,

     

    I have tested with persisted test case sample. it doesn't moving to the next task, after signalling after reloading the session. But it is working fine with the same session(with out reloading)... .

     

    I am trying the reload of session as below.

     

         ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(ksessionId, kbase, null, env);

     

    Is anyone tested the signalling after reload of session? Can you provide the solution for this...

     

     

    Thanks,

    Ravichandran

  • 7. Re: Signal Event is not happening in persisted process
    Maciej Swiderski Master

    could you attach your test case that shows the issue?

  • 8. Re: Signal Event is not happening in persisted process
    ravichandrankg Newbie

    Hi Maciej,

     

    i am testing with the following code.

     

         Map props = new HashMap();

         props.put("filename", "test.txt");

     

         String username = "krisv";

         props.put("actorid", username);

     

         ProcessInstance instance = jbpmsession.startProcess(DsrPocConstants.PROCESS_ID_NAME, props);

         jbpmsession.insert(instance);

     

         Environment env = null;

         env = ksession.getEnvironment();

         KnowledgeSessionConfiguration config = ksession.getSessionConfiguration();

     

         // reload knowledge session

         ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id, kbase, config, env);

         new JPAWorkingMemoryDbLogger(ksession);

         KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);

         JPAProcessInstanceDbLog processLog = new JPAProcessInstanceDbLog(ksession.getEnvironment());

         ksession.getWorkItemManager().registerWorkItemHandler("Human Task",wsHumanTaskHandler);

     

         processmanager.getKnowledgeSession().signalEvent("validatewithshowevent", null, processmanager.getProcessId());

         processmanager.getKnowledgeSession().signalEvent("qcvideotask", null, processmanager.getProcessId());

     

    i am keeping breakpoint in the following line (in eclipse), and completing the human task from eclipse human task viewer.

         processmanager.getKnowledgeSession().signalEvent("validatewithshowevent", null, processmanager.getProcessId());

     

    after that, i am continuing the signal part.

     

    It is not giving any error. But it is not moving to the next task.

     

    But if we try with out reloading the session part, it is moving to the next task. Can you please check, what i am missing here. If you have any test case with persistence stuff, can you please try with signalling stuff and confirm the same?

     

     

    Thanks,

     

    Ravichandran

  • 9. Re: Signal Event is not happening in persisted process
    Maciej Swiderski Master

    Are you sure that human task is completed properly? What I suspect is that when you reload the session and register work item handler for  Human Task the handler is not connected to task server so it will not get notification about completed task. Try with invoking connect method on the WSHumanTaskHandler.

     

    Best would be if you could provide maven project with process and test case, that would allow me to quickly review what's inside and confirm if that is a bug or not.

     

    HTH

  • 10. Re: Signal Event is not happening in persisted process
    nbd Newbie

    I didn't read much into your problem, but I think it's not the issue with signaling events at all. The problem is different - process instances don't continue their execution at all after reloading a session.

    Look here: https://community.jboss.org/message/759786.