Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 3.22 KB

File metadata and controls

47 lines (32 loc) · 3.22 KB

EIPinCPI: Correlation Identifier

Recipes by Topic | Recipes by Author | Request Enhancement | Report a bug | Fix documentation

Bhalchandra Wadekar Bhalchandra Wadekar

This recipe lets you try out Correlation Identifier pattern using AMQP Adapter.\

When sending the request, the sender adds a unique key to request. The receiver processes the request and puts the unique key as the Correlation Identifier in the reply message. Thus when a reply is received independent of the request, the sender knows the request corresponding the received reply based on the Correlation Identifier.\

This pattern is a variant of the Request Reply pattern.

Download the integration flow for Enqueueing Customer
Download the integration flow for Processing Customer
Download the integration flow for Processing Response

Recipe

Step Code Why?
Enqueue Customer
Process Customer Content Modifier step ‘Prepare Response Message’ has the following addition to the ‘Message Header’ tab. | Action: Create | Name: JMSCorrelationID | Type:String | Data Type | Value : /Customer/Id | Default: | add the Correlation Identifier by setting header ‘JMSCorrelationID’ as Customer’s Id
Process Response see code

Related Recipes

  • Request Reply: This recipe retrieves a list of products using the Request-Reply pattern
  • Return Address: This recipe lets you try out Return Address pattern

References

Sample integration flows

Sample Code for Process Response


def Message processData(Message message) {

    def messageLog = messageLogFactory.getMessageLog(message)
    messageLog.addAttachmentAsString('Response for Customer: ' + message.getHeader('JMSCorrelationID', String), message.getBody(String), null)

    return message
}```

### Sample Output
![Output](Correlation%20Identifier%20-%20Output.png)