Skip to Content
Technical Articles
Author's profile photo Jacky Liu

Use CPI AMQP adapter to test BTP Event Mesh

In the situation of extesionsibility options determination like the following picture, to keep core system clean,for loose coupled application extension, we recommand to use side-by-side extensibility on BTP. In decoupled application, BTP Event Mesh play an important role.  We can realize some requirements with Integration instead of side by side extention.Today I will demo how use CPI AMQP adapter to test BTP event mesh.In my following blogs, I will introduce how to use CPI to realize  some logic triggered by  S/4 Hana Cloud event .

Prerequisite:

  • For Event Mesh, you have finished the following 3  steps:

  1. Get Started with the Event Mesh User Interface
  2. Setting Up SAP Event Mesh in BTP Cockpit
  3. Creating an Event Mesh Instance Using the Default Plan,you will event mesh instance service key like the following:

Testing Steps:

1, Create Event queue as help .

 

2 Create oauth2 client credential in CPI

3 Create and deploy iflow in CPI to consume event from event queqe in Event Mesh

/* Refer the link below to learn more about the use cases of script.
https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/148851bf8192412cba1f9d2c17f4bd25.html

If you want to know more about the SCRIPT APIs, refer the link below
https://help.sap.com/doc/a56f52e1a58e4e2bac7f7adbf45b2e26/Cloud/en-US/index.html */
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
    //Body
    def body = message.getBody(java.lang.String);
    
    def messageLog = messageLogFactory.getMessageLog(message)
    
        if (messageLog != null) {
        messageLog.addAttachmentAsString('Em content', body, 'text/plain')
    }
    return message;
}

4 Create and deploy iflow in CPI to produce event to event queqe in Event Mesh

 

5 Use postmen to send message  to eventissue iflow in step4

6 Check result in iflow of event consuption

 

The End!

 

Thanks for your time!

Best Regards!

Jacky Liu

 

 

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jacky Liu
      Jacky Liu
      Blog Post Author

      Hi Mastan,

       

      The following is the json file I used to create EM instance for your reference .

       

      {
      "options": {
      "management": true,
      "messagingrest": true,
      "messaging": true
      },
      "rules": {
      "topicRules": {
      "publishFilter": [
      "${namespace}/*"
      ],
      "subscribeFilter": [
      "sap/S4HANAOD/cap1/*",
      "${namespace}/*"
      ]
      },
      "queueRules": {
      "publishFilter": [
      "${namespace}/*"
      ],
      "subscribeFilter": [
      "sap/S4HANAOD/cap1/*",
      "${namespace}/*"
      ]
      }
      },
      "version": "1.1.0",
      "emname": "camemconsue-em",
      "namespace": "sap/cap/so"
      }

      Author's profile photo Frank Li
      Frank Li

      Hi Jacky,

       

      Thanks for your sharing. Is your exercises in this blog can be achieved by BTP Trial Account?

      Author's profile photo Jacky Liu
      Jacky Liu
      Blog Post Author

      Hi, Frank,

       

      You can finish this excercise in Trial account .

       

      https://discovery-center.cloud.sap/serviceCatalog/event-mesh?region=all&tab=service_plan&commercialModel=free

      https://discovery-center.cloud.sap/serviceCatalog/integration-suite?region=all&tab=service_plan&commercialModel=free

       

      Best regards!

      Jacky Liu

      Author's profile photo Sreehari V Pillai
      Sreehari V Pillai

      Hi Jacky - thanks for this. I am an absolute beginner in CPI ( and integration tools) .

      Question : When you configured Sender adapter for AMQP , you maintained the queue name . Lets say I have a queue in event mesh . And I post messages with 2 topic names "TopicA" and "TopicB". I want the integrator to pick only "TopicA" ( TopicB is for another purpose lets say ) . Can I configure like this ? Or the listener should always be on the queue for all the topics ?

       

      Sreehari