Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
bhalchandraswcg
Contributor

Previous - Message Sequence | Index | Next - Format Indicator


This week, we're going to study Message Expiration pattern.

When do I use this pattern?


This pattern is applied when messages have to be processed within a given time. For example, a sender may not be interested in flight prices after a minute.

Message Expiration in CPI


In CPI, I will demonstrate the example using AMQP Receiver Adapter. In AMQP Receiver Adapter, Expiration Period can be set in the number of seconds. If nothing is specified, the default value of the specified queue or topic applies.

The example for Message Expiration pattern is similar to the examples for Return Address and Correlation Identifier patterns.

Step 1: Enqueueing Flight Price Request


This integration flow starts immediately and enqueues the flight price request in 'flightpricerequests' queue.



The only difference to the examples from the Return Address and Correlation Identifier patterns is the request body and the configuration in the Processing tab of AMQP Adapter.

The request body is:
{
"Origin": "BHX",
"DepartureDate": "2020-05-01",
"Destination": "BOM",
"ReturnDate": "2020-06-01"
}

And, the configuration in the Processing tab of the AMQP Adapter is:























Parameter Value
Destination Type Queue
Destination Name flightpricerequests
Expiration Period 60
Delivery Non-Persistent

Here, the expiration period is set to 60 seconds because the sender is not interested in flight prices after a minute.

Step 2: Processing Flight Price Requests




Again, this is similar to examples from Return Address and Correlation Identifier patterns. The difference is the response body and the Processing tab of AMQP Receiver Adapter.

The response body is:
{
"Currency": "GBP",
"Price": "400"
}

And, the configuration in the Processing tab of the AMQP Receiver Adapter is:























Parameter Value
Destination Type Queue
Destination Name flightprices
Expiration Period 60
Delivery Non-Persistent

Again, the expiration period is set to 60 seconds because the sender is not interested in flight prices after a minute.

Note that setting expiration period to 60 seconds means the message will stay alive in the queue for longer than the sender expects it. The extra time message will stay alive in the queue is the amount of time taken by the receiver to process the request and to put the response in the 'flightprices' queue.

Step 3: Processing Flight Price


For simplicity, as usual, the response is logged for monitoring.


Conclusion


Message Expiration pattern is used when processing the message after a certain time is not required.

References/Further Readings



Hope this helps,
Bala

Previous - Message Sequence | Index | Next - Format Indicator

Labels in this area