Wednesday 20 July 2016

Anatomy of Conversation and Correlation

During my interaction with Oracle BPM developers I frequently notice that the concept of "Conversation" is not clear to most. When inquired about "Conversation", most of them used to state that "Conversation" is used when inter-process communication is required from within a multi-instance subprocess but they fails to explain why ? "Correlation" is the popular method used in inter process communication and can even be used to carryout inter process communication from multi-instance subprocess, when why we use "Conversation" ? What are those scenarios which "Correlation" cannot handle and "Conversation" is the way to go ?

Before explaining the scenarios,  let me spend couple of lines to explain the similarities and differences between "Correlation" and "Conversation".

"Correlation" is a technique to attach a business attribute to the instance of a process to uniquely identify that process instance while communicating with that process instance from outside (outside of the process). For an Order Fulfillment process you may have a step which invokes (through Send Task or Throw Message) Order Shipment process asynchronously and wait (in Receive Task or Catch Message) for the response. In this case, to enable  Order Shipment process instance to send the response back to that specific instance of Order Fulfillment process correlation can be used. Correlation is initiated in the Send Task and used in the Receive Task of the Order Fulfillment process. OrderId could be used as correlation property if uniquely identify a Order Fulfillment process instance. The Send Task of Order Shipment process should pass OrderId as argument to Receive Task of Order Fulfillment process, where the same is used in correlation to indetify the instance associate with OrderId.



The above mentioned inter process communication can also be implemented without Correlation, using Conversation.

Unlike Correlation, Conversation does not require unique attribute association. System automatically keeps track of instance that has initiated the conversation and when receiving the response backed from called processes it can automatically identify the specific instance of the calling process

To implement the above mentioned process using Conversation, we will do little bit of twicking. Remove the correlation used in SendTask and ReceiveTask of Fulfillment process and create a Conversation in the structure pane of the Fulfillment process.


Next we need to the implementation of Send Task and Receive Task of Fulfillment process to use the Conversation we just created instead of calling Shipment process directly.


In the earlier approach you might have called the ReceiveTask of Fulfillment process directly from SendTask of Shipment process, however when we implement the communication using Conversation we must implement the SendTask of Shipment process as asynchronous call back as follows -


So we observed that in the above mentioned scenario either Correlation or Conversation can be used, be the communication initiated from the SendTesk on the main process or from within multi-instance subprocess. However Correlation cannot be used when you cannot attach a unique business identifier to a process instance, generally which is the case for instances in a multi-instance subprocess. In those cases Conversation is only way to go.

Apparently  though "Advanced Conversation" looks superior as compared to "Correlation" or messaged based conversation, the major shortcoming of "Advanced Conversation" is - not all client has the capability to initiate a conversation. Consider a scenario where your order fulfillment process is waiting at a Message Catch activity for an external j2ee system to notify the process instance about the order shipment status. In this case conversation cannot be used as the external j2ee system would not be able to participate in the conversation. "Correlation" should be used in this case.

NotePlease note that "Correlation" is a form of "Conversation", it is message based conversation. And by "Conversation" we generally refer to "Advanced Conversation".


No comments:

Post a Comment