Correlation Again!
Last week I had a question about correlation sets from Dave, one my colleagues in the financial services team. Now Dave is pretty smart but it seems that correlation was confusing him, like it seems to do a lot of people. So I thought I would go back to basics and talk about what correlation does.
What does correlation do?
Basically correlation has two key uses.
- Allow the BPEL Process Manager to deliver incoming messasges to the correct BPEL process instance.
- Validate that outgoing messages should be part of this correlation.
Correlation for Message Delivery
Correlation is usually only an issue when we are using correlation sets. In conjunction with use 1 there are two ways correlation sets are used.
- To initialise the correlation set based on an incoming or outgoing message. This is is the 'init' property set to true. This registers a particular set of correlation set values as the identifier for the process, telling the BPEL PM that any messages with those particular values in the correlations set should be routed to this process. This can be done in either an invoke or in a receive, but it can be done only once and must be done before any other use is made of the correlation set.
- The other use of a correlation set is to identify which parts of an incoming message should be used to identify the target process instance. This is the flip side of step 1. It is only used on a receive.
So we can initialise a correlation set on an invoke (outbound or inbound portion of invoke) and we can route messages to the correct process instance on a receive. This leaves us with using an initialised correlation set in an invoke.
Correlation for Processs Instance Validation
Remember that correlation sets can also be used to validate that messages are part of the correct process instance. This is done by using an initialised correlation set on an invoke (either the outbound or inbound portion). This causes the BPEL PM to validate that the values in the message match the values in the correlation set. Any mismatch causes a Correlation Fault to be raised.
The Original Question
So waht was the original question? Well one of Dave's customers was confused by the 'pattern' attribute. The base fo the confusion was the lack of understanding what correlation does. 'pattern' just specifies the way in which correlation sets will be used within an invoke. The possible settings for pattern within an invokes' correlation tag are shown below
- initiate='true' - This is the usage of initisalising the correlation set.
- pattern='out' - set the correlation on the outbound message
- pattern='in' - set the correlation on the inbound message
- pattern='out-in' - I don't think this is valid and I believe that this will cause an error (haven't tried it though!)
- initiate='false' - this is the default setting and is the usage of validating the correlation set on an invoke.
- pattern='out' - validate outbound message (request)
- pattern='in' - validate inbound messsage (response)
- pattern='out-in' - validate message both ways.
Hopefully this will help clarify correlation.