This week, we study another variation of Message pattern known as Document Message.
When do I use this pattern?
A Command Message invokes functionality in the target system, whereas, a Document Message is just a message sent to the target system. A Document Message does not tell the receiver system what to do with the message. Examples of the Document Message pattern include a response message from an invoked SOAP operation and sending an Email.
Document Message in CPI
A response message from an invoked SOAP operation
Last week, I commanded W3 Schools to convert 37 ℉ to Celsius. The full response message from W3Schools is:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Here, the content between Body element is a document message returned to CPI without telling CPI what to do with it. CPI chose to log that response for monitoring.
Sending an Email
Another example of Document Message is sending an Email. When an email is sent, the email server is free to choose the future of the received message. Some examples of future actions taken by the email server are to assign a tag to the email, move the email to the junk folder, add a line at the top to say “This Email is from External Network. Be careful when clicking on links.”, and so on.
This is a simple integration flow. It starts as soon as it is deployed and sends the email document.
Similar to previous flows in this blog series, this integration flow starts immediately after deployment using the configuration of Run Once in Timer Start.
For configuring the Mail Adapter, I’ll refer you to the blog: Gmail Connectivity from CPI.
Here are the configurations I used:
When integration flow is deployed, I receive the email in my Google Account.
The code is available as Integration Recipe on SAP’s official repository: EIP-MessageConstruction-DocumentMessage
Document Message pattern is a variation of Message pattern. Unlike the Command Message pattern, Document Message pattern does not include telling the receiver system what to do with the message.
Hope this helps,
About the Author
More Content by Bhalchandra Wadekar