4 Replies Latest reply on Dec 5, 2012 12:16 PM by thomas.setiabudi

    How to signal process event from a custom WorkItemHandler?

    thomas.setiabudi

      Hi,

       

      I use JBPM5.4 and my process is started by JBPM Console.

       

      Is it possible to signal event to a process instance from within a custom implementation of WorkItemHandler? or Service Task?

       

       

      If that is possible, how do we do it? is there any sample code for it?

       

       

       

      Regards,

      Thomas Setiabudi

        • 1. Re: How to signal process event from a custom WorkItemHandler?
          swiderski.maciej

          in general I would recommend to signal it using intermediate throwing signal event. But if you need to do it from within the work item handler you need to use ksession for that. So, when you register your handler make sure to inject ksession into it and the use it to signalEvent.

           

          HTH

          • 2. Re: How to signal process event from a custom WorkItemHandler?
            thomas.setiabudi

            Hi Maciej,

             

            Thank you for your answer.

             

            If I were to make a custom WorkItemHandler and need to inject ksession to it, that means instead of registering my workitemhandler in

            jbpm-installer\jboss-as-7.1.1.Final\standalone\deployments\jbpm-gwt-console-server.war\WEB-INF\classes\META-INF\CustomWorkItemHandlers.conf

             

            I would need to inject it in

            \jbpm-installer\jboss-as-7.1.1.Final\standalone\deployments\jbpm-gwt-console-server.war\WEB-INF\classes\default.session.template

             

            and change this part

             

             workItemHandlers = ["Human Task" : "new my.custom.workitemhandler.humantask.hornetq.CustomHTHornetQWIH(\"jbpmConsoleHTHandler\", taskClient, ksession, org.jbpm.task.utils.OnErrorAction.LOG)",
                                    "Service Task" : "new org.jbpm.process.workitem.bpmn2.ServiceTaskHandler(ksession)"],
            

             

            to

             

             

             workItemHandlers = ["Human Task" : "new my.custom.workitemhandler.humantask.hornetq.CustomHTHornetQWIH(\"jbpmConsoleHTHandler\", taskClient, ksession, org.jbpm.task.utils.OnErrorAction.LOG)",
                                    "Service Task" : "new org.jbpm.process.workitem.bpmn2.ServiceTaskHandler(ksession)",
                                      "MyCustomTask" : "new my.custom.workitem.handler.myWorkItemHandler(kession)"],
            

             

            and then register a .wid for MyCustomTask.

             

            will that works?

             

             

            Regards,

            Thomas Setiabudi

             

            • 3. Re: How to signal process event from a custom WorkItemHandler?
              swiderski.maciej

              you don't have to change the default.* files inside the jbpm-gwt-console-server.war as you can simply make a copy of these files and drop them in configuration directory (for AS7 it is jboss_home/standalone/configuration), e.g. rename copied default.session.template to session.template and add your modification. Console when loading first checks if there is a custom file in config dire and if so load it instead of default ones. More on this can be found in documentation as well.

               

              Yes, it should work as you described

               

              HTH

              • 4. Re: How to signal process event from a custom WorkItemHandler?
                thomas.setiabudi

                Allright,

                 

                Thank you Maciej

                 

                 

                Regards,

                Thomas Setiabudi