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.
STEP- 6 : Verifying in the SAP Event Mesh- Messaging Administration
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.