Please provide some additional detail as it is difficult to understand exactly what you are asking.
What i want is not to insert my java service task in a pool but to passivate its behaviour and only complete such task when an external signal is received and/or a callback is called.
start->service task 1-->Receive Task-->End
In the Service Task i'm calling the third party service.
In the third party service once the request received it will send success ack and then it will further process the request, once after the action performed it will send us the callback with the correlation id.
In this example i need to wait in the service task till get the callback.
Could you please help me to achieve this functionality with some example.
Thanks in advance.
Ah yes, this is a very standard pattern (especially with service oriented architectures) and there are a number of ways to solve it.The simplest is to follow your service call with an intermediate message receive event as shown below:
The problem with this approach is that you need to implement some sort of device to actually correlate with and release the token when it is waiting on the intermediate catch event. Typically this is handled using a custom REST endpoint that you create and that your external service calls.Details of creating a custom REST endpoint in Enterprise Edition can be found here:Activiti Enterprise Developer Series - Custom REST Endpoints The approach is almost the same for Community edition.
If this is not what you are looking for, a second option is to create an Asynchronous service task that extends the org.activiti.engine.impl.bpmn.behaviorAbstractBpmnActivityBehavior class.
This will give you access to the signal method along with the usual execute method available for javaDelegates.Signal is used to "signal" the service to complete and you will tie this into your callback receiver class.
A nice example of how to use this approach can be found here:
camunda-bpm-examples/servicetask/service-invocation-asynchronous at master · camunda/camunda-bpm-examples · GitHub The example above is for Camunda, but works exactly the same way (except for package names) in Activiti.Hope this helps,
Thank you very much for the above two approaches. its really helpful.
I would like to know is their any inbuilt feature in activiti to handle the correlation by engine its self.
If not is there any other bpm tools supports by default?
We make extensive use of the Activiti's Camel interface for attaching to different messaging engines and data sources for this sort of thing. The Activiti Camel module provides the ability to call camel routes as well as receive messages from camel sources. Check out the following write up for details:BPMN 2.0 / Activiti: Using Camel routes in Activiti made really easy
If you are using Enterprise Edition, there are additional steps required to add camel to the build which you can find described here:
Using the Camel task to invoke a Camel route
However, if you are looking for process to process communication, you can use signals rather than messages.Signals differ a little in that they can be thought of as more of a publish and subscribe pattern, one process can throw a signal, all processes listening for that signal will handle it.
Retrieving data ...