ignazw
ignazw

Reputation: 129

How to send signals to Activiti processes asynchronously

I want to decouple process definitions from service implementations, and communication between java code of (micro) services and the Activiti processes should be via REST interface only.

Business processes are often asynchronous by design, and are perfect to interact with using publsih-subscribe-channel integration patterns. (cf http://www.eaipatterns.com/PublishSubscribeChannel.html)

However, it seems I cannot interact with Activiti using message channels.

Simplified example. Let's say I have a process where the customer orders some products, resulting in an order p, and then the process waits for the payment of order p, which I expect within a certain time t, after which I get an automatic cancel event.

I hope to get many orders, which means I will have many running process instances. Each instance uses the orderID as a variable.

My n process instances are now listening for a paymentReceived event for a specific orderId.

Incoming payments are handled by a different architectural component, which has to send the paymentReceived signal for a specific orderId. It would be ideal to publish this event onto a channel.

It seems Activiti has no channel interface, and can only be triggered by calling it directly. I can call the runtime, I can call the process instances and execution, but as the calling party I have to figure out myself which of these instances or executions is actually the one that is waiting for the specific paymentReceived signal. As a caller, I have to correlate the orderId from the event with the orderId from the process instance.

Hence, if I want to use a publish/subscribe architecture, I have to write code, e.g., a message driven bean which performs the task of figuring out which process instance is waiting for my specific event.

I would expect this kind of channel-subscription code to be part of the BPM tool. Apparently this is not so for Activiti, which means Activiti is not a loosely coupled system usable in an enterprise-wide SOA.

Or did I miss something? Is there any way to use messaging patterns with Activiti in a loosely coupled way?

Any alternatives?

Upvotes: 0

Views: 3365

Answers (1)

mooreds
mooreds

Reputation: 4978

I think you're correct. You could write a message listener which will then start an Activiti process, wait for the results, and then push results back onto another queue, or use some other SOA pattern.

You might want to look at the http://www.activiti.org/userguide/#bpmnReceiveTask and see if that fits your needs.

But I don't see any great support within Activiti for this.

Upvotes: 1

Related Questions