Skip to Content
Technical Articles

EIPinCPI – Message Store

Previous – Message History | Index | Next – Smart Proxy

This week, I’ll explore a system management pattern known as Message Store.

When do I use this pattern?

Message Store is used to persist the message or parts of it for reporting and analytics purpose. The Message can be stored in the persistence using a Wire Tap or by using a dedicated step.

Message Store in CPI

Storing the Message

In CPI, the message can be stored in Message Store using Persist step like so:

Persist

Persist

This flow starts immediately using the Timer Start Event, then Content Modifier step sets a Header, a Property, and the body of the message. Finally, Persist step will persist the message into the Message Store.

Accessing the Message

The persisted message can be accessed using CPI’s OData API.

Fetch the Message ID

First, let’s run the flow. When the flow is deployed we can view the Message ID in monitoring.

Deployed

Deployed

Get the Message Store Entry using the Message ID

Now, I can use the Message ID to fetch the message store entries by running HTTP GET on the URL:

https://<Tenant>/api/v1/MessageProcessingLogs(‘<Message ID>’)/MessageStoreEntries

Example output is like below. Here, we can see the entry for the Persist step from the flow.

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://<Tenant>:443/api/v1/">
    <id>https://<Tenant>:443/api/v1/MessageStoreEntries</id>
    <title type="text">MessageStoreEntries</title>
    <updated>2021-01-31T15:27:57.116Z</updated>
    <author>
        <name/>
    </author>
    <link href="MessageStoreEntries" rel="self" title="MessageStoreEntries"/>
    <entry>
        <id>https://<Tenant>:443/api/v1/MessageStoreEntries('sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b')</id>
        <title type="text">MessageStoreEntries</title>
        <updated>2021-01-31T15:27:57.116Z</updated>
        <category term="com.sap.hci.api.MessageStoreEntry" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <link href="MessageStoreEntries('sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b')" rel="edit" title="MessageStoreEntry"/>
        <link href="MessageStoreEntries('sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b')/$value" rel="edit-media" type="application/octet-stream"/>
        <link href="MessageStoreEntries('sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b')/Attachments" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" title="Attachments" type="application/atom+xml;type=feed"/>
        <link href="MessageStoreEntries('sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b')/Properties" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Properties" title="Properties" type="application/atom+xml;type=feed"/>
        <content type="application/octet-stream" src="MessageStoreEntries('sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b')/$value"/>
        <m:properties>
            <d:Id>sap-it-res:msg:a237a07a6:d8402-e38e-4d13-9567-998eb2af638b</d:Id>
            <d:MessageGuid>AGAWw8xxrAL7yJjy8kCGivUFXGQH</d:MessageGuid>
            <d:MessageStoreId>Persist</d:MessageStoreId>
            <d:TimeStamp>2021-01-31T14:50:52.396</d:TimeStamp>
            <d:HasAttachments>false</d:HasAttachments>
        </m:properties>
    </entry>
</feed>

 

Get the Body of the Message

The body of the message can be viewed by visiting the /$value path

https://<Tenant>/api/v1/MessageProcessingLogs(‘<Message ID>’)/MessageStoreEntries(‘sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b’)/$value

The example output could be:

<Body />

Get the Headers of the Message

The headers are available at the /Properties path

https://<Tenant>/api/v1/MessageProcessingLogs(‘<Message ID>’)/MessageStoreEntries(‘sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b’)/Properties

The example output is like below. Here, we can see standard headers like SAP_MplCorrelationId, SAP_PreGeneratedMplId, and SAP_MessageProcessingLogID. Custom header ‘Header’ is also listed here.

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://<Tenant>:443/api/v1/">
    <id>https://<Tenant>:443/api/v1/MessageStoreEntryProperties</id>
    <title type="text">MessageStoreEntryProperties</title>
    <updated>2021-01-31T15:36:33.128Z</updated>
    <author>
        <name/>
    </author>
    <link href="MessageStoreEntryProperties" rel="self" title="MessageStoreEntryProperties"/>
    <entry>
        <id>https://<Tenant>:443/api/v1/MessageStoreEntryProperties(MessageId='sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b',Name='SAP_MplCorrelationId')</id>
        <title type="text">MessageStoreEntryProperties</title>
        <updated>2021-01-31T15:36:33.128Z</updated>
        <category term="com.sap.hci.api.MessageStoreEntryProperty" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <link href="MessageStoreEntryProperties(MessageId='sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b',Name='SAP_MplCorrelationId')" rel="edit" title="MessageStoreEntryProperty"/>
        <content type="application/xml">
            <m:properties>
                <d:MessageId>sap-it-res:msg:a237a07a6:d8402-e38e-4d13-9567-998eb2af638b</d:MessageId>
                <d:Name>SAP_MplCorrelationId</d:Name>
                <d:Value>AGAWw8whkIvH4abnnWdrJ8C12kO_</d:Value>
            </m:properties>
        </content>
    </entry>
    <entry>
        <id>https://<Tenant>:443/api/v1/MessageStoreEntryProperties(MessageId='sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b',Name='Header')</id>
        <title type="text">MessageStoreEntryProperties</title>
        <updated>2021-01-31T15:36:33.129Z</updated>
        <category term="com.sap.hci.api.MessageStoreEntryProperty" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <link href="MessageStoreEntryProperties(MessageId='sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b',Name='Header')" rel="edit" title="MessageStoreEntryProperty"/>
        <content type="application/xml">
            <m:properties>
                <d:MessageId>sap-it-res:msg:a237a07a6:d8402-e38e-4d13-9567-998eb2af638b</d:MessageId>
                <d:Name>Header</d:Name>
                <d:Value>Value</d:Value>
            </m:properties>
        </content>
    </entry>
    <entry>
        <id>https://<Tenant>:443/api/v1/MessageStoreEntryProperties(MessageId='sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b',Name='SAP_PregeneratedMplId')</id>
        <title type="text">MessageStoreEntryProperties</title>
        <updated>2021-01-31T15:36:33.129Z</updated>
        <category term="com.sap.hci.api.MessageStoreEntryProperty" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <link href="MessageStoreEntryProperties(MessageId='sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b',Name='SAP_PregeneratedMplId')" rel="edit" title="MessageStoreEntryProperty"/>
        <content type="application/xml">
            <m:properties>
                <d:MessageId>sap-it-res:msg:a237a07a6:d8402-e38e-4d13-9567-998eb2af638b</d:MessageId>
                <d:Name>SAP_PregeneratedMplId</d:Name>
                <d:Value>AGAWw8xzG5YwLr1SYPHGi9qi_IR8</d:Value>
            </m:properties>
        </content>
    </entry>
    <entry>
        <id>https://<Tenant>:443/api/v1/MessageStoreEntryProperties(MessageId='sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b',Name='SAP_MessageProcessingLogID')</id>
        <title type="text">MessageStoreEntryProperties</title>
        <updated>2021-01-31T15:36:33.129Z</updated>
        <category term="com.sap.hci.api.MessageStoreEntryProperty" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <link href="MessageStoreEntryProperties(MessageId='sap-it-res%3Amsg%3Aa237a07a6%3Ad8402-e38e-4d13-9567-998eb2af638b',Name='SAP_MessageProcessingLogID')" rel="edit" title="MessageStoreEntryProperty"/>
        <content type="application/xml">
            <m:properties>
                <d:MessageId>sap-it-res:msg:a237a07a6:d8402-e38e-4d13-9567-998eb2af638b</d:MessageId>
                <d:Name>SAP_MessageProcessingLogID</d:Name>
                <d:Value>AGAWw8xxrAL7yJjy8kCGivUFXGQH</d:Value>
            </m:properties>
        </content>
    </entry>
</feed>

Please note that here the path /Properties does not mean Exchange Properties, the path /Properties stores headers of the message.

If other standard headers for the sender, receiver, message type, application id are populated before persisting, then, using UI5 it will be easy to build reports based on these factors. For example, finding out the number of messages by a given sender of a given message type.

EIPinCPI Rating – 10/10

CPI has dedicated step and OData API to access the Message Store. Therefore, a complete 10 out of 10 rating is given.

Conclusion

Message Store is used for storing the message for reporting or analytics purpose.

References/Further Readings

Hope this helps,
Bala

Previous – Message History | Index | Next – Smart Proxy

Be the first to leave a comment
You must be Logged on to comment or reply to a post.