Skip to Content
Technical Articles
Author's profile photo Ramya P

Guide: Step By Step Procedure To Send And Receive Messages in a SAP Event Mesh Instance

Hello everyone!

In the recent past, I have been exploring so many SAP BTP capabilities as part of my work and out of interest.

This is my first blog post on the enterprise-messaging capability of SAP.  This service allows components to communicate through asynchronous events and distributes business events from SAP and non-SAP sources across hybrid landscapes.

Introduction

SAP Event Mesh is a dynamic service that helps applications, services, and systems interact with each other through messages and events.

Solving the issue of scalability, SAP Event Mesh enables the reliable exchange of messages between sender and receivers.

The message broker works like a charm! We have the sender application, a message broker, and a receiver application, which could be one or many. Asynchronous communication takes place between the application, services, or systems wherein the sender application isn’t bogged down by waiting for a response from the receiver and the Reciever(s) can subscribe to critical business needs and can consume the messages on their own pace.

 

In this blog post, I would be detailing the step-by-step procedure to send messages to the queue and consume them as well using the REST API tool POSTMAN.

 

Please note that a detailed tutorial already exists, and this blog post is an improvisation of that.

 

 

Pre-Requisite:

Event Mesh Instance- Detailed steps are provided here

 

Procedure to Send Messages to the Queue 

STEP -1  : Setting up POSTMAN

  • Open the POSTMAN application or on a browser, and create a new request.

 

 

STEP -2 : Authorization Configurations

Click on the Authorization tab in Postman and click on the drop-down menu from Type and choose OAuth 2.0.

 

 

Provide a user-friendly Token Name and choose the Grant Type as Client Credentials and get the Access Token URL from the Event Mesh Instance Service Key.

 

STEP- 3:  Header Configuration

In the header of your postman add x-qos in the key and a value of either 0 or 1 in the VALUE section

QOS means Quality of Service.

It denotes the way the messaging protocol handles retransmission of the message and ensures its delivery regardless of network reliability.

 

If the QoS is 0, the service tries to deliver the message and returns an HTTP response with code 204 irrespective of whether the message is delivered, also the message is deleted from the queue without an acknowledgment from the client.

If the QoS is 1 delivery of the message is guaranteed, and the service responds with the HTTP response code 204. If the 204 response code isn’t received, it’s the client’s responsibility to retry until the response code 204 is received.  The message is deleted from the queue only after the acknowledgment is consumed

STEP- 4:  URL Configuration

Build the postman URL as shown below:

https://<uri of the rest protocol based section from Service Keys>/messagingrest/v1/queues/<Queue name>/messages. It is the uri at the end of the document.

 

So your final link should look like this:

https://enterprise-messaging-pubsub.cfapps.us10.hana.ondemand.com/messagingrest/v1/queues/test/messages

Here ‘test’ is the queue name.

 

STEP- 5 :  Sending Message

Type a message and click on send if the status is 204 No Content, which means, the message has been sent successfully.

You can check the same in the event mesh instance page you previously created.

Sending%20message%20to%20event%20mesh%20using%20POSTMAN

Sending a message to event mesh using POSTMAN

 

STEP- 6 : Verifying in the SAP Event Mesh- Messaging       Administration

 

Queue%20gets%20updated

 

Queue gets updated

 

 

 

Procedure to Consume Messages from the Queue

The first two steps remain the same.

For consuming the messages we previously sent, all we have to do is change the URL.

Build the postman URL as shown below:

https://< uri of the rest protocol based section from Service Keys>/messagingrest/v1/queues/<Queue name>/messages/consumption

 

The final link should look like this:

https://enterprise-messaging-pubsub.cfapps.us10.hana.ondemand.com/messagingrest/v1/queues/test/messages/consumption

Here ‘test’ is the queue name.

On hitting the send button you should be able to see the messages you previously sent and the status code being 200 OK.

 

Conclusion

This blog post provides a detailed step-by-step procedure for you to update a queue in the event mesh using the REST API tool POSTMAN and also the procedure to consume those messages.

In the upcoming blog post, I will be writing about using the AMQP adapter to send messages to a topic and consume the message from queues via email and an open connector.

Further Reading

  • https://blogs.sap.com/2022/03/13/btp-event-mesh-advance-concepts/
  • https://blogs.sap.com/2022/03/04/data-events-scenario-with-sap-event-enablement-add-on-for-sap-s-4hana-sap-event-mesh-and-sap-cloud-integration-step-by-step-guide/

 

A Like would be encouraging and motivating. Please let me know in the comments if you found this blog post helpful and if you have any suggestions/questions.

Assigned Tags

      15 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Pradeep Panda
      Pradeep Panda

      thanks Ramya for being a volunteer for Event Mesh 🙂

       

      regards

      Pradeep

      Author's profile photo Ramya P
      Ramya P
      Blog Post Author

      Hi Pradeep,

       

      My pleasure, Pradeep. Thank you so much for all the blogs on Event Mesh. 🙂

      Author's profile photo Nandhini Ramasamy
      Nandhini Ramasamy

      Great Ramya.. Thank you for the detailed  blog on Event Mesh..!!!

      Author's profile photo Ramya P
      Ramya P
      Blog Post Author

      Thank you so much Nandhini for reading and I am glad it was helpful.

      Author's profile photo Syambabu Allu
      Syambabu Allu

      Hi Ramya,

      Great blog…Thanks sharing!!

      Thank you,

      Syam

      Author's profile photo Ramya P
      Ramya P
      Blog Post Author

      Hi Syambabu,

      My pleasure. I am glad it was helpful.

       

      Thanks,

      Ramya

      Author's profile photo Sumandeep Kaur
      Sumandeep Kaur

      Great work on Event Mesh Ramya....

      Author's profile photo Ramya P
      Ramya P
      Blog Post Author

      Thank you Suman! 🙂

      Author's profile photo Arshi .
      Arshi .

      Thankyou Ramya. Really helpful. 🙂

      Author's profile photo Ramya P
      Ramya P
      Blog Post Author

      Hi Arshi,

      Its a pleasure, Arshi. I am glad it was helpful.

      Author's profile photo Susmita Moharana
      Susmita Moharana

      Great Job Ramya..Very helpful.

       

      Author's profile photo Susmita Moharana
      Susmita Moharana

      Great Job Ramya. Veryful helpful.

      Author's profile photo Jay Adnure
      Jay Adnure

      Hi Ramya,

       

      Thank you for this blog. I am looking for a node mqtt client and consume the event mesh instance. I am not sure how to handle the oauth2.0 authentication in node mqtt client. Do you have any reference article for this?

       

      kr,

      Jay

      Author's profile photo Tobias Griebe
      Tobias Griebe

      Hi Jay Adnure,

      SAP offers the node mqtt client lib: https://www.npmjs.com/package/@sap/xb-msg-mqtt-v311

      This contains a consumer example, you only need to adopt the configuration file with the Event Mesh credentials and you can run it from your local machine.

      Best regards,
      Tobias

      Author's profile photo Jay Adnure
      Jay Adnure

      Hi Tobias,

       

      thanks for sharing I am able to modify the config file and connect to the broker.

       

      kr,

      Jay