Tuesday, July 28, 2020

Correlation in SOA

Few Concept we need to understand to know about Correlation

Correlation is an important concept in SOA to manage the flow of messages or requests, especially in scenarios involving asynchronous communication or long-running processes.

Message Tracking: Correlation in SOA helps track and associate messages or requests as they move through various services or components within a distributed system.

Use of correlation sets to ensure that asynchronous callbacks locate the appropriate client.

Why is Correlation Important:

Asynchronous Communication: In SOA, services often communicate asynchronously, meaning that requests and responses are not sent and received immediately. Correlation is crucial for matching a response with its original request, even if there is a time delay between them.

Long-Running Processes: In business processes that involve multiple steps and potentially take a long time to complete, correlation ensures that all related activities are associated with the correct process instance.

Synchronous & Asynchronous web services:

Whenever a synchronous web service is invoked from Oracle BPEL via a partnerlink, only one port is established for communication with the exposed web service which is used by both request & response messages.

When an asynchronous web service is invoked, two ports are opened for communication. one for request & one for response messages.

CORRELATION ID

A correlation ID unique to the client request.

Correlation happens while runtime process where multiple processes may be waiting for service callbacks, Oracle BPEL Server must know which BPEL process instance is waiting for a callback message

The correlation ID enables Oracle BPEL Server to correlate the response with the appropriate requesting instance.

Correlation Id: A common approach to implementing correlation is to assign a unique identifier (correlation ID) to each request or message. This ID is included in the message payload or message headers.

Message Routing: As messages or responses are received by various services, the correlation ID is used to route them to the appropriate destination or process.

Context Management: Correlation IDs are often used to manage the context of a specific interaction, allowing services to link responses back to the original request.

Use Cases for Correlation in SOA:

Order Processing: In e-commerce systems, when a customer places an order, the system generates a unique correlation ID for that order. As the order progresses through various stages (payment processing, shipping, etc.), the correlation ID ensures that all related actions are tied to that specific order.

Workflow Management: In workflow automation, correlation helps manage complex, multi-step processes. Each step or activity can be associated with a specific process instance using a correlation ID.

Asynchronous Communication: Correlation is essential in scenarios where a service initiates an asynchronous operation (e.g., sending a request to a message queue) and later needs to link the response back to the original request.


Correlation set

Using the Correlation set we can override the default implementation (WS-Addressing) by the “Content based” to use request data.

Why & Where Correlation?

1.    When the external web service called doesn't have WS-Addressing capability

2.    use correlation sets to ensure that asynchronous callbacks locate the appropriate client.

3.    When the message travels through several services and the response is requested by the initial service from the last service directly.

Ex: when the conversation is in the form A > B > C > A instead of A > B > A.

Implementing Correlation in SOA:

The following are few scenarios in which we would be required to implement Correlation to identify & relate message communication;


a.) Creating Correlation Sets:

·         In Structure Window of the JDeveloper IDE, right click on the Correlation Sets and
 choose 'Create Correlation Set'

·       Provide a name for your correlation set being created.

·       In the properties section, select 'Add' to display the property chooser window

·        Choose 'Create' to create a property on which the correlation has to be initiated.

·      Provide a name and type for the property.


b.) Associating the Correlation set on receive/invoke, pick activities 

·         Go the the correlations tab on the activity (invoke/receive/pick) on which you need to set & validate the correlation

·         Add the created correlation set to the activity

     Initiate Attribute: (Value Set - yes, no)

Ø  When set to yes, correlation set is initiated with the values of the properties available in the message being transferred

Ø  When set to no, correlation set validates the value of the property available in the message

    Pattern Attribute: (Value Set - in, out, in-out)

Ø  When the value is 'in', it means that the correlation property is set/validated on the incoming message

Ø  When the value is 'out', it means that the correlation property is set/validated on the message going out of BPEL

Ø  In case of 'in-out', the property will be set/validated on both incoming & outgoing messages

    

c.) Creating Property Alias:

Ø  In the Structure Window of the JDeveloper, right click on the 'Property Aliases' and select 'Create Property Alias'

Ø  Select the message type that you want to set to the correlation property (already created)

Ø  Now, correlation design is complete. However, correlation will not be established unless we reference the correlations on the WSDL file of the BPEL process.

Ø  To do this, import the correlation WSDL file (created under the project) in the BPEL process main WSDL.


How does Oracle BPEL identify asynchronous responses?

WS-Addressing (default) or Correlation

WS-Addressing?

WS-Addressing defines the concept of Endpoint References (EPRs), which are used to uniquely identify the endpoints of web services. 

An EPR typically includes information such as the service's address (URL), the reference properties (e.g., security information), and a reference parameters block.

By default, Oracle BPEL PM implements WS-Addressing for all asynchronous web service calls, hence we don't have to explicitly implement identification relationship between the incoming & outgoing messages.

How WS-Addressing is Used in SOA:

Message Routing: WS-Addressing enables dynamic message routing by specifying the destination endpoint for a message. This is particularly useful in scenarios where a message needs to traverse multiple intermediaries before reaching its final destination.

Asynchronous Communication: WS-Addressing is often used in asynchronous communication patterns. The "Reply To" property allows a service to specify where the response to a request should be sent, which is essential for asynchronous processing.

Reliable Messaging: WS-Addressing can be employed to facilitate reliable messaging by ensuring that messages are uniquely identified (using the "Message ID" property) and that responses are correlated with their respective requests.

Message Exchange Patterns: WS-Addressing is compatible with various message exchange patterns, including one-way, request-response, and callback patterns, making it suitable for a wide range of SOA scenarios.

Security: WS-Addressing can be used in conjunction with WS-Security to enhance the security of web service interactions in SOA. It allows you to specify security-related addressing information, such as the "To" and "Action" properties.

In summary, WS-Addressing in SOA provides a standardized way to include addressing information in SOAP messages, allowing for more flexible, reliable, and secure web service communication. It plays a vital role in enhancing the capabilities of web services within a service-oriented architecture by enabling features such as message routing, asynchronous communication, reliable messaging, and security.

WS-Addressing in an Asynchronous Service

WS-Addressing plays a significant role in facilitating asynchronous communication in web services within a Service-Oriented Architecture (SOA). When dealing with asynchronous services, WS-Addressing allows you to manage and track asynchronous messages effectively. Here's how WS-Addressing is used in an asynchronous service:

1. Correlation of Messages:

In an asynchronous service, a client sends a request message to a service, and instead of waiting for an immediate response, it expects a response at a later time.
WS-Addressing is used to correlate the response message with the original request. It typically includes a unique "Message ID" in the request and "Relates To" information in the response to link them together.

2. Message Destination (Reply To):

WS-Addressing allows the client to specify where the response should be sent by including a "Reply To" endpoint reference (EPR) in the request message. This means the service knows where to send the response when it's ready.
3. Tracking Message Status:

WS-Addressing can be used to track the status of asynchronous messages. The "Message ID" helps uniquely identify each message, and you can include properties like "Action" to indicate the desired action or operation to be performed.
4. Callback Mechanism:

In many asynchronous scenarios, the client provides a callback mechanism or endpoint in the "Reply To" EPR. This callback endpoint is where the service sends the response when it's ready. This allows the client to continue its work without blocking.
5. Handling Faults:

WS-Addressing is also used to handle faults and errors in asynchronous services. When a fault occurs, WS-Addressing ensures that the fault message is correlated with the original request for proper error handling.
6. Guaranteed Delivery:

WS-Addressing, when used with reliable messaging protocols, ensures that messages are not lost and are delivered to the correct destination. It helps in achieving guaranteed message delivery in asynchronous scenarios.

Example of WS-Addressing in an Asynchronous Service:

Let's consider a scenario where a client initiates a long-running data processing task through a web service:

The client sends a request to the service, including a unique "Message ID" and a "Reply To" EPR indicating where to send the response.

The service acknowledges the request and starts the data processing task. It might provide periodic status updates.

When the task is completed, the service sends the response back to the "Reply To" EPR provided by the client, using WS-Addressing to ensure proper correlation with the original request.

If an error occurs during processing, the service can send a fault message to the "Reply To" EPR, again using WS-Addressing to link it to the original request.

In this example, WS-Addressing enables the client and the service to communicate asynchronously while ensuring that messages are correlated, responses are sent to the correct destination, and errors are handled appropriately.

Overall, WS-Addressing is a crucial component in designing and implementing asynchronous services in a SOA, providing the necessary addressing and correlation mechanisms to support robust and reliable communication.








 



6 comments:

  1. Nice blog thanks for all information.

    ReplyDelete
  2. Thanks Diksha for providing the detailed information on co-relation. This is really very helpful.

    Keep it up !!

    ReplyDelete
  3. Please provide such information on some other topics in SOA as well, e.g Authentication, user creation in LDAP etc

    ReplyDelete
    Replies
    1. Thanks for your comment, sure I will provide more details in LDAP concept. For Authentication you can refer below link:
      https://teachmesoa.blogspot.com/2020/07/authentication-for-client-service.html

      Delete

SOA Overview Part-1

  Middleware It provides a mechanism for the process to interact with other processes running on multiple network machines. Advantages...