9 Replies Latest reply on Mar 1, 2010 12:20 PM by Jens Augustsson

    BPMN 2.0 Service Task

    David Geary Newbie

      In the BPMN service task in JBPM 4.3 you define the service operation to call as (eg from the example)

       

      <bpmn:interface id="myInterface" name="org.jbpm.examples.bpmn.task.service.JavaService">
              <bpmn:operation id="myOperation" name="myMethod">
                  <bpmn:inMessageRef>inputMessage</bpmn:inMessageRef>
                  <bpmn:outMessageRef>outputMessage</bpmn:outMessageRef>
              </bpmn:operation>
      </bpmn:interface>

       

      From what I can see in the example unit test this creates a new instance of the specified java class (JavaService) when the process executes, in fact if you call the method twice it creates the object twice.

       

      Surely a service is more likely to have a lifecycle external to the process? How can I 'inject' a prexisting service instance into the process? Specifically is it possible to access externally defined spring beans?

       

      Thanks

        • 1. Re: BPMN 2.0 Service Task
          Ronald van Kuijk Master

          From what I can see in the example unit test this creates a new instance of the specified java class (JavaService) when the process executes, in fact if you call the method twice it creates the object twice.

          Correct, that is the behaviour. The default service type in BPMN2.0 (http://www.omg.org/spec/BPMN/2.0/) is 'webservice'  (you can see the high BPEL type overhead here). What the behaviour of services should be is not explicitly mentioned in the spec afaik (did not look at it lately) but webservices are mostly stateless, as are java services (tasks) in jPDL, so it is not strange that they are to be seen as stateless.

           

          Surely a service is more likely to have a lifecycle external to the process?

           

          No, not in this scope. That is more going towards orchestrations or conversations in BPMN

           

          How can I 'inject' a prexisting service instance into the process?

          Injecting them is not possible (yet?) but resolving classes, variables etc like in jPDL will probably be implemented one way or another in the future. More flexibility will be achieved then

           

          Specifically is it possible to access externally defined spring beans?


          No, not afaik, but see the answer to the previous question.

           

          Cheers,

           

          Ronald

          1 of 1 people found this helpful
          • 2. Re: BPMN 2.0 Service Task
            David Geary Newbie

            Thanks for the reply - very useful, but Im still wondering is it in any way possible to wire in collaborating objects to the service task instance eg other service objects, remoting, messaging, database etc - I cant see much use for a standalone class to be constructed unless it comunicates with something else?

             

            Or are these service tasks just supposed to execute some local logic in java eg performing a calculation and return the result? What would be a typical example?

             

            From what you said would I be correct in assuming there will at some point be support for the expression lanaguage to resolve bean references eg like in the current spring support in jpdl?

             

            Thanks again

             

            Dave

            • 3. Re: BPMN 2.0 Service Task
              Bernd Ruecker Master

              Hey Dave.

               

              You have to do that basically yourself. Either calling a EJB or getting a Spring bean or using Google Juice or whatever from this class. Obviously you are right, the typical use case is to call a real service. But this is up to you how you use the engine.

               

              Cheers

              Bernd

              • 4. Re: BPMN 2.0 Service Task
                Ronald van Kuijk Master

                Bernd is right... It could e.g. be calling a 'local' esb that in turn does something remote or like jPDL will have in 4.4, an 'EJB service' where you configure jndi name etc... For the moment, be creative...;-) Do whatever you want do do from the java class.

                 

                Ronald

                • 5. Re: BPMN 2.0 Service Task
                  David Geary Newbie
                  OK, but surely I stll need to be able to get a reference to the local ESB or to JNDI or a spring application context etc ie ideally I need dependency injection on the constructed class. The only way I can see to do this for now would be to use static fields or do a hard coded lookup.
                  • 6. Re: BPMN 2.0 Service Task
                    Ronald van Kuijk Master
                    or pass a variable that contains the correct info (look at what is passed e.g. to the jPDL ejb node
                    • 7. Re: BPMN 2.0 Service Task
                      Jens Augustsson Newbie

                      Hi,

                       

                      To me this looks as a sweet place to use CDI - then that service could IRL be an EJB, JavaBean, have a life cycle etc. Is there any particular reasoning against getting the reference within jBPM using CDI? JSE5 compatibility I guess? And the fact that the CDI spec came only two weeks before your 4.3 release...

                       

                      Nice work, ya'll.

                       

                      br,

                      Jens

                      • 8. Re: BPMN 2.0 Service Task
                        Ronald van Kuijk Master

                        Is there any particular reasoning against getting the reference within jBPM using CDI?

                         

                        4.4 will have (some form of?) support for CDI afaik
                        JSE5 compatibility I guess?

                         

                        Hmmm... not sure how CDI influences jBPM in this regard...  afaik JSE5 is still the target. Maybe CDI is backwardscompatible?

                         

                        And the fact that the CDI spec came only two weeks before your 4.3 release...

                         

                        Yep... played a big part.

                        • 9. Re: BPMN 2.0 Service Task
                          Jens Augustsson Newbie

                          kukeltje wrote:

                          JSE5 compatibility I guess?

                           

                          Hmmm... not sure how CDI influences jBPM in this regard...  afaik JSE5 is still the target. Maybe CDI is backwardscompatible?

                           

                          Quite right, I ran to the Weld site and checked: "Java SE 5.0 and above". Great, thus not an obstacle.