EIPinCPI – Service Activator

This week, we’ll learn one of the most common patterns known as Service Activator.

When do I use this pattern?

Service Activator acts as a translator between the service exposed by the Message Endpoint and the messaging system. For example, an OData service can be consumed in CPI using a Service Activator commonly known to us developers as OData Receiver Adapter.

Service Activator in CPI

In CPI, I’ll demonstrate the OData Receiver Adapter as a Service Activator.

Integration Flow


OData Service

The integration flow starts immediately using Timer Start Event, gets the product from Northwind OData Service using OData Receiver Adapter, and Logs the message contents using a Groovy Script.

The Service Activator is implemented as OData Receiver Adapter. The OData Receiver Adapter invokes the OData service using HTTPS, the HTTP response body is converted to a nicer format and stored into the message body. whereas headers are copied into message headers. A CamelHttpResponseCode header is also set.

The Log Groovy Script shows us the content of the Message. The script is like so:

import com.sap.gateway.ip.core.customdev.util.Message

def Message processData(Message message) {
    def messageLog = messageLogFactory.getMessageLog(message)

    messageLog.addAttachmentAsString('Headers', message.headers.collect { key, value ->
        key + ':\t' + value
    }.join('\n'), null)
    messageLog.addAttachmentAsString('Body', message.getBody(String), null)

    return message



CamelHttpResponseCode: 200
HttpStatusCodes: OK
ODataResponseType: Properties
SAP_MessageProcessingLogID: AF-DILhznrDxdh_O8s9gq-HkSMD8
SAP_MplCorrelationId: AF-DILgcLpXDWMgi0y190B6yKRrJ
SAP_PregeneratedMplId: AF-DILhK89mz6lm-NFvqmuw9SM3M
scriptFile: script1.groovy
scriptFileType: groovy


        <QuantityPerUnit>10 boxes x 20 bags</QuantityPerUnit>

As you can see the raw HTTP response from OData service was nicely wrapped in a Message by the Service Activator.

EIPinCPI Rating – 10/10

CPI has a number of out-of-the-box Service Activators, called as Adapters for most common protocols and applications. A developer can also develop adapters if required. In addition, the Cloud Platform Integration Suite has Open Connectors that allow connection to many applications. Therefore, CPI has a full rating of 10/10 for the Service Activator pattern.


Service Activator pattern enables us to consume and provide services from the messaging system without the consumer/producer having knowledge of the messaging code.

References/Further Readings

Hope this helps,

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 – Publish-Subscribe Channel
EIPinCPI – Publish-Subscribe Channel

Next Article
EIPinCPI – Message Channel
EIPinCPI – Message Channel