8 Replies Latest reply on Jan 19, 2012 9:09 AM by mbraud

    How to fire action events in jBPM5 ? (BPMN2.0)

    markboletti

      Hi all,

      we have a workflow system built using old Oracle Workflow which has a set of triggers (stored procedures) fired when for example a task is completed or when the token enters one node.

      I have knowledge how to implement this with jBPM 3 via a generic action handlers, however I'd like to invest in jBPM 5 which seems very promising.

       

      I have took a look at BPMN 2.0 documentation, however I could not find any idea how to fire a Java trigger using BPMN 2.0.

       

      For example, I have found documented a Java Service Task, however I could not find a way to fire a java class every time a node is entered or left

      I wonder if there's a way how to do this....otherwise we have to stay on jBPM 3......

      Thanks a lot in advance,

      Mark

        • 1. How to fire action events in jBPM5 ? (BPMN2.0)
          krisverlaenen

          Take a look at domain-specific work items.  They are a special type of Task nodes that allow you model an invocation in the process as a custom node type and then register a handler, which is a simple Java class that can then invoke anything you like.

           

          https://hudson.jboss.org/hudson/job/jBPM5/lastSuccessfulBuild/artifact/target/jbpm-5.0-SNAPSHOT-docs-build/jbpm-docs/html/ch06.html

           

          Kris

          • 2. How to fire action events in jBPM5 ? (BPMN2.0)
            markboletti

            Hi Kris,

            thank you very much for you reply. Well, according to the docs, I have created a work definition file and added in the META-INF folder of my project a rools.rulebase.conf which registers the workdefinition.

            However the service task is not included in Eclipse palette so I cannot add it from the visual editor.

            In the docs it is shown to appear in the Eclipse service task palette.

            Has anybody managed to register a new work definition file successfully ?

            thanks a lot

            Mark

            • 3. How to fire action events in jBPM5 ? (BPMN2.0)
              krisverlaenen

              I've created a screencast about how to create your own node types a while ago.  You could try following that to see whether that works or what you might be doing differently:

               

              http://people.redhat.com/kverlaen/DomainSpecificWorkItem.swf

               

              Note that this screencast uses a new Drools project to get started, but it also works if you create a new jBPM5 project (I just verified to be sure).

               

              Kris

              • 4. Re: How to fire action events in jBPM5 ? (BPMN2.0)
                tomathome

                Hi,

                 

                i tryed the screencast and everything works fine. Very importand is to put the

                 

                "customEditor" : "org.drools.eclipse.flow.editor.GenericModelEditor",

                 

                line in your definitions file, which is unfortunatelly hidden in the screencast.

                 

                 

                Is there any way to integrate my new created WorkItemHandler with guvnor? If I use the integration jbpm-console - guvnor - eclipse with the last jbpm5-snapshot, then I do not start the jbpm-engine for selfe and have no idea how to get the StatefullKnowledgeSession -> WorkItemManager to register my created WorkItemHandler. Any Ideas?

                 

                Tom

                • 5. Re: How to fire action events in jBPM5 ? (BPMN2.0)
                  salaboy21

                  Hi there,

                  I'm not sure to understand your question. I'm not a guvnor /  jbpm console fan, but I think I can help you to solve the problem.

                  If you want to bind a workItemHandler to your knowledgeSession you can use the APIs:  ksession.getWorkItemManager().register("name", handler);

                  Greetings.

                  • 6. Re: How to fire action events in jBPM5 ? (BPMN2.0)
                    tomathome

                    Thanks @Mauricio,

                     

                    My question was exacle how to get the "ksession" instance, if the jBPM engine was started by the jBPM console and is running in the web context.You are starting your jBPM process for selfe and so you have the full controll to the jBPM API. For me the jBPM engine is just the black-box, running and managed by the jBPM console.

                    • 7. Re: How to fire action events in jBPM5 ? (BPMN2.0)
                      salaboy21

                      Ok, now I understand your problem. So there are basically two options:

                      1) Expose the jBPM-Console created sessions, so you can interact with them using a remote APIs

                      2) Let the jBPM-Console use sessions that were created from outside applications, or add the posibility to register custom work item handlers to the sessions created by the jbpm-console.

                       

                      About 1, there is a way to do that already using Drools Server. But we need to integrate it with the jBPM-console

                       

                      About 2, I'm 90% sure that you can do it right now.. I've already seen some questions about that, but I don't remember the solution right now.. I probably will take a look on that..

                       

                      Hope it helps, if you don't find the solution, please report a jira issue with your requirement as a feature request, we will evaluate it and work on it.

                      Greetings!

                      • 8. Re: How to fire action events in jBPM5 ? (BPMN2.0)
                        mbraud

                        Hi Mauricio,

                         

                        I have some questions regarding option 1) Expose the jBPM-Console created sessions, so you can interact with them using a remote APIs

                        How do you do that?

                         

                        Here is my problem: We are using the jBPM-console to start processes. Our processes are using asynchronous behaviour on the service tasks (aka WorkItemHandler). The workItemHandler is simply sending a web service request to an external system. Later on, we receive a callback from the external system and we need to call kSession.signalEvent() in order to kick off the next step in the process.

                        We are controlling the web service interface so that the external system returns in the callback the workitemID that we sent as part of the original request, thus we know which processInstance to continue but the problem is that we also need the KnowledgeSession!

                        We could modify the web service interface and pass (and thus get returned) both the workitemID and the sessionID but I don't even know how to get hold of the jBPM-console internal sessionID from within a WorkItemHandler.

                        I can see that the Session started by the jBPM-console is persisted in the database (SESSIONINFO table in the H2 database) but I don't know how to get hold of it from within the WorkItemHandler.

                         

                        We also start some of our processes using java code and they run within a separate session so we have more than one session running at the same time, so how to know which one a process started from the jBPM console is actually using?

                         

                        Thanks in advance for the help!