Friday, May 11, 2012
Oracle BPEL 11g - Correlation Sets
Correlation
Sets is as set of configurations that allow the process to receive
messages during its execution even if the invoker doesn't have the
Correlation ID necessary to indicate to the engine to which instance
the message needs to be delivered. With Correlation Sets a group of
business data can be used to inform the engine how to match the message
received with the correct instance that is already in execution.
To understand correlation sets is necessary to know some main concepts:
Itens below is a step-by-step showing how to configure Correlation Sets:
1 - Create a new operation in the process interface, allowing it to receive a message during process execution
![]()
![]()
![]()
2 - Change the process to use the new operation during the process execution
![]()
![]()
3 - Create and initialize the Correlation Set with business value that will be used to match the message that will be received
![]()
![]()
![]()
![]()
4 - Match the incoming message
![]()
![]()
![]()
![]()
![]()
![]()
With this configuration, BPEL engine can match business value
stored in the property (initialized in the first Receive activity)
with the the message value received by the Intermediate Operation and
deliver the message for the correct running instance.
![]()
To download this sample, click here.
|
Labels: BPEL, Correlation
BPEL - Correlation, fault handling, and compensation
The previous entries have covered the fundamentals of BPEL, providing
an understanding of the activities defined and how they can be combined
together using structured activities and the The invoke activity exhibits a short-cut mechanism for defining handlers directly on its definition. The behavior is effectively that it becomes wrapped in a scope that will have these specified handlers. BPEL defines a set of built-in faults that notify of errors such as assignment type mismatches, a scope forcing the termination of a nested scope, and activating a reply activity that doesn't have a matching receive activity. The BPEL engine is responsible for detecting these faults and throwing them to the appropriate scope. Compensation While a business process is running, it might be necessary to undo one of the steps that have already been successfully completed. The specification of these undo steps are defined using compensation handlers that can be defined at the scope level. Each handler contains one activity which is run when a scope needs to be compensated. The activities within such a handler must see the container data to be that which it was when the scope completed. Due to activities sharing containers and loops caused by while activities, completing scopes that are compensation-enabled must save a snapshot of the data for the handler to possibly use later. Once a scope completes successfully, its compensation handler becomes ready to run. This can happen in either of two cases: explicit or implicit compensation. Explicit compensation occurs upon the execution of a compensate activity. This activity may occur anywhere, and refers to the name of the scope that it wants compensated. Scopes that might be rolled back in this manner must therefore be named. BPEL further specifies that names of scopes must be unique within a BPEL process. When a compensate activity is reached, it runs the compensation handler on the specified scope. On the other hand, implicit compensation occurs when faults are being handled and propagated. Consider the scenario in which a scope A contains a compensatable scope B that has completed normally, but then another nested activity in A throws a fault. Implicit compensation ensures that whatever happened in scope B gets undone by running its compensation handler. Therefore, implicit compensation of a scope goes through all its nested scopes and runs their compensation handlers in reverse order of completion of those scopes. |
Labels: BPEL, Compensation, Correlation, Fault Handling
Correlation Sets
BPEL CorrelationWhere Did I Put That Process?A BPEL process is initiated and makes a call to an ERP system to raise a purchase order, generating a purchase order number. Later that purchase order causes another system to raise an invoice and send the invoice to the BPEL process. How does the BPEL engine know which BPEL process should receive this invoice and process it. This is dealt with a thing called correlation.From e-mails and phone calls that I receive it appears a lot of people struggle with BPEL correlation. It seems that the questions falls into two categories, why would I want it, and how do I do it? What is Correlation?Correlation is basicallly the process of matching an inbound message to the BPEL engine with a specific process. Normally this matching is hidden from us. Synchronous calls have no need of correlation because the conversation context is maintained on the stack or across a TCP connection. Consenting BPEL processes will usually correlate messages using WS-Addressing headers to pass around magic tokens that act like the session cookies in a web application. Why Do I Need Worry About It?Well most of the time you don't! As I mentioned before, calling another BPEL process or using a synchronous call will mean you don't have to think about it. You do need to worry about it in the following situations amongst others.
How Do I Get the Right Process Instance?BPEL provides a construct called a correlation set to allow for custom correlation. A correlation set is a collection of properties used by the BPEL engine to identify the correct process to receive a message. Each property in the correlation set may be mapped to an element in one or more message types through property aliases as shown below. Things to Remember About CorrelationI see some common misunderstandings about custom correlation. So lets knock them off now.
A Quick Guide to Custom CorrelationEnough of the theory, how does it work in practice? Consider a process A that call a process B that calls a process C that calls a process A. This is one of the scenarios (113) in the BPEL samples distributed with Oracle BPEL PM. So we have a cycle A->B->C->A. Three different asynch calls. Note only process A needs correlation because only A receives more than one call. On the invoke from A to B we add a correlation in the correlation tab for the invoke using BPEL Designer. In here we will create the correlation set and create a property to correlate the exchange. We set this to initiate the correlation, meaning that it will associate this process with the given value. On the receive from C to A we add the same correlation set with its property as we did for the invoke from A to B. However this time we mark the receive as not to initiate the correlation, meaning that the BPEL PM will use this to select the right process instance. We now go to the BPEL structure diagram in the BEL Designer and add the property alias. We create two property aliases maping to appropriate elements in each message that will have the same value in message from A to B, as in the message from C to A. Note that the elements can be different names and in different structures in the two messages, but they must contain the same value if correlation is to work. At this point BPEL designer has done almost everything. We need to manually edit the bpel.xml file and add the following XMl fragment to each partner link that will participate in the correlation.
Note that " correlationSet" is a fixed value. I have uploaded a sample of this process. Note deploying it may be tricky due to circular dependencies. How to deploy it is left as an exercise to the reader, but if the worst comes to the worst deploy an empty version of the process B, then deploy process A, then process C and then the real process B. |
Labels: Correlation
Wednesday, May 9, 2012
BPEL Correlation
Labels: BPEL, Correlation



















