1 Reply Latest reply on Oct 18, 2012 7:27 AM by swiderski.maciej

    JBPM and Webservice call with callback - please advise

    mvermand

      Hi,

       

      I'm quite new to JBPM5, though have worked quite a lot with JBPM4.4.

       

      We are investigating if we can switch to JBPM5.

      I need to create a Task in a bpmn flow that sends a message to an external webservice.

      Lets call this Task-A.

      Moreover, the external party must respond (async) within a definable time (for example 1 hour or 1 day...)

      Only if the external party responds within this time period,Task-A can be completed and the next task can be started.

      Else a different (error-reporting/fallback) task should be started.

      If no response arrived in time, Task-A should be marked as terminated/obsolete(?) so in case a response of the external party arrives afterwards, this has no effect anymore.

       

      Can you give me any ideas in how to accomplish this?

       

      Challenge 1: Creating a callback to complete the Task-A:

       

      I found something similar (I think) in an example called "PersistentEmergencyServiceProcess", though

      I'm not sure it is a good staring point since:

      1) this handles about human tasks

      2) it has an ActiveWorkItemService.java class which states:

      * This class doesn't support ksession crashes. The ksession passed to its

      * constructor must leave through all the process execution.

       

      ==> what if the server get's restarted within the life-span of 1 hour or 1 day?

       

      Challenge 2: Creating a duedate/timeout on the Task-A:

       

      In JBPM4.4 it is quite easy to set a timer (duedate) on a task.

      How can this be done in JBPM5?

      I do not see such property on a Task in the JBPM Editor.

       

      Challenge 3: How to call an external webservice:

       

      Are there any available helper-classes to easely achieve this?

      Or should I just generate POJO from a WSDL and call this code from a bean?

       

       

      Any advice will be greatly appreciated!

       

      Michiel

        • 1. Re: JBPM and Webservice call with callback - please advise
          swiderski.maciej

          mvermand wrote:

           

          Challenge 1: Creating a callback to complete the Task-A:

           

          I found something similar (I think) in an example called "PersistentEmergencyServiceProcess", though

          I'm not sure it is a good staring point since:

          1) this handles about human tasks

          2) it has an ActiveWorkItemService.java class which states:

          * This class doesn't support ksession crashes. The ksession passed to its

          * constructor must leave through all the process execution.

           

          ==> what if the server get's restarted within the life-span of 1 hour or 1 day?

          It can be modeled in several ways, to name few:

          1. use custom work item handler that sends web service requests but does not complete work item and provide custom endpoint that will receive response and complete appropriate work item

          2. use service task to invoke web service operation in fire and forget mode then use event based gateway to split the flow into two branches one with intermediate catch signal event and the other with timer - signal event waits for response from your service - of course you need to have an endpoint that will receive response and signals the process

           

          Personally prefer option 2 as it gives more visibility on the process what happens, just a note that event based gateways could have some issues but it is on todo list so will get better if required.

           

           

          mvermand wrote:

           

          Challenge 2: Creating a duedate/timeout on the Task-A:

           

          In JBPM4.4 it is quite easy to set a timer (duedate) on a task.

          How can this be done in JBPM5?

          I do not see such property on a Task in the JBPM Editor.

          For this you should use boundary timer events that is attached to a task. It has capability to cancel task that is attached to and continue with alternative path.

           

           

          mvermand wrote:

          Challenge 3: How to call an external webservice:

           

          Are there any available helper-classes to easely achieve this?

          Or should I just generate POJO from a WSDL and call this code from a bean?

           

          Take a look here, it describes runtime engine support for web service invocation.

           

          HTH