EIPinCPI – Document Message

December 15, 2019 Bhalchandra Wadekar

This week, we study another variation of Message pattern known as Document Message.

When do I use this pattern?

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">
    <soap:Body>
        <FahrenheitToCelsiusResponse xmlns="https://www.w3schools.com/xml/">
            <FahrenheitToCelsiusResult>2.77777777777778</FahrenheitToCelsiusResult>
        </FahrenheitToCelsiusResponse>
    </soap:Body>
</soap:Envelope>

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.

Integration Flow

This is a simple integration flow. It starts as soon as it is deployed and sends the email document.

Steps

Start Immediately

Similar to previous flows in this blog series, this integration flow starts immediately after deployment using the configuration of Run Once in Timer Start.

Mail Adapter

For configuring the Mail Adapter, I’ll refer you to the blog: Gmail Connectivity from CPI.

Here are the configurations I used:

Tab Parameter Value
Connection Address smtp.gmail.com:587
Connection Authentication Plain User/Password
Connection Credential Name Gmail Credentials
Connection From My Email Address
Connection To My Email Address
Connection Subject EIPinCPI
Connection Mail Body Hello, World!

Output

When integration flow is deployed, I receive the email in my Google Account.

Integration Recipe

The code is available as Integration Recipe on SAP’s official repository: EIP-MessageConstruction-DocumentMessage

Conclusion

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.

References/Further Readings

Hope this helps,
Bala

About the Author

Bhalchandra Wadekar

Bhalchandra Wadekar is an Integration Enthusiast who authored the Enterprise Integration Patterns in SAP Cloud Platform Integration (#EIPinCPI) series on SAP Blog Community. He is a fan of integration from API Management and Open Connectors to Message Based Integration and Data Integration.

More Content by Bhalchandra Wadekar
Previous Article
EIPinCPI – Command Message
EIPinCPI – Command Message

Next Article
EIPinCPI – Message
EIPinCPI – Message