Part 4: Discover and consume Event APIs from SAP Developer Hub
Share

One of the key benefits of making Event APIs available through SAP Developer Hub is enabling a self-service experience for developers. Whether they are internal developers or external developers and business partners, they can discover Event API Products, subscribe to it, and use the credentials provided by the Developer Hub to consume the events themselves or publish events.

This blog is Part 4 of a four-part series, covering the journey from setting up Advanced Event Mesh to consuming Event APIs through Developer Hub:

  1. Part 1: Enabling Advanced Event Mesh for API Management
  2. Part 2: Connecting Advanced Event Mesh and Developer Hub
  3. Part 3: Publishing event APIs on Developer Hub and managing API Products
  4. Part 4: Discover and consume Event APIs from SAP Developer Hub

You don’t need to have followed the previous parts to complete this tutorial. In this part, we’ll take the perspective of a developer using Developer Hub: we’ll discover an Event API Product, subscribe to it, retrieve the required credentials, and use them to connect to the Event Broker and consume events.

We’ll cover the following:

Before you start (prerequisites):

  1. Be onboarded as an Application Developer in the Developer Hub.
  2. Have access to a client where you can test the connectivity to the Event Broker, in this example I’m using the “Try Me!” in SAP Integration Suite, Advanced Event Mesh
  3. Optionally: Have viewing rights to the Event Portal and Application Domain in your Advanced Event Mesh environment

Event API Products: Discover and Subscribe 

  1. Go to the home page of the Developer Hub and go to your API Product containing event APIs.
    Picture 1.png

     

  2. Under “Events”, you see an overview of the event APIs that are part of this product. “Rate Plan” gives you details on the rate plan that is linked to it the event API Product (defines messaging type, access type, queue type, etc.), “Associated Subscriptions” list which applications are subscribed to this Event API Product. Feel free to browse these different tabs.
  3. Now, let’s subscribe to the Event API Product, click on the button “Subscribe” on the right top and create the application (either create a new subscription or add it to an existing API application). 
    Picture 2.png
  4. If you’re creating a new API Application, enter a name (e.g. Sales Order Application) and optionally a short text and a description and press “Create“. 
    Picture 3.png

     

  5. Once you created the application, you will be automatically redirected to the application. Later, you can find the application in the Developer Hub under “My Workspace“. 
    Picture 4.png
  6. In the application, you will find the credentials you can use to authenticate to the event broker/event API. “Key” will serve as your username and “Secret” as your password. For this tutorial, copy these credentials
    Picture 5.png

     

  7. When consuming events using guaranteed messaging, the application consumes them from a queue. This allows messages to be stored on Advanced Event Mesh if the application is temporarily unavailable or cannot process messages as quickly as they are generated. In this case, you will also need the name of your queue, you find this in your application by going to “Products“, select your Event API Product, under “Queue Details” you find the name of your queue. Also copy the name of the queue for this tutorial.
    Picture 6.png

     

  8. Optionally: if you have access to the event portal in Advanced Event Mesh (optional), you will see that after the creation of an application in the Developer Hub a new application is created in your Application Domain.
    Picture 7.png

     

Event APIs: Publishing and Consuming

For publishing events to and/or consuming events from Event APIs using your credentials from the Developer Hub, you can use any client as long as you are able to specifcy the following:

  • Broker URL (e.g.  https://mr-connection-xxxxx.messaging.solace.cloud:9443)
  • Message VPN 
  • Client Username (key copied from Developer Hub)
  • Client Password (secret copied from Developer Hub)
  • Queue Name (name copied from Developer Hub)
  • Topic (found in the Async API spec on the Developer Hub)

Make sure your Queue Name and Topic are in line with the documentation. The key and secret provided are only whitelisted for the topics and queues that are part of the Event API Products in your API Application. If you try to subscribe or publish to a topic that is not included in the API Product, the operation will fail.

⚠️If you don’t know which Broker URL or Message VPN should be used, reach out to one of your administrators in SAP Integration Suite, advanced event mesh.

To demonstrate how the connection works, I will use “Try Me!” in Advanced Event Mesh.

  1. In SAP Integration Suite, advanced event mesh, go to “Cluster Manager➡️ select your Broker Service ➡️ click on “Try Me!” and at the left bottom of the page, hit “Open Broker Manager“.
  2. In “Try Me!“, enter the following under “Publisher“:
  3. Make sure under “Subscriber” you checked “ Same as Publisher
  4. Hit “Connect” at both the “Publisher” as the “Subscriber” side.
  5. You should now see the word “Connected” under “Establish Connections“. 
    Picture 11.png

     

  6. Once the connection is established, scroll down to “Bind to an endpoint to receive guaranteed messages” on the “Subscriber” side:
    1. Select “Queue
    2. Enter the queue name copied from the Developer Hub
    3. Hit “Start Consume
    4. You should now see that the consumer is active
      Picture 12.png

       

  7. If you were able to subscribe to the queue, scroll down to “Publish to topic” on the “Publisher” side:
    1. Enter the topic you want to publish on (needs to be part of an Event API Product where your API Application is subscribed to)
    2. Delivery Mode can remain “Direct”
    3. Enter a payload under “Message Content
    4. Hit “Publish”
  8. After publishing events on the topic, you should see the messages appearing on the right side of the page (under “Subscriber”). This means that the messages are successfully being published on the topic and landing in the queue, using the credentials generated by creating an API Application. 
    Picture 13.png

     

What’s next 

You’ve now seen how developers can discover, subscribe to, and consume Event APIs through SAP Developer Hub using a self-service approach.

This concludes our journey from setting up Advanced Event Mesh to enabling a self-service experience for developers to consume Event APIs through Developer Hub.

If you want to see the complete picture and how the different pieces fit together, head back to the main blog, which provides an overview of the full series.

 

 One of the key benefits of making Event APIs available through SAP Developer Hub is enabling a self-service experience for developers. Whether they are internal developers or external developers and business partners, they can discover Event API Products, subscribe to it, and use the credentials provided by the Developer Hub to consume the events themselves or publish events.This blog is Part 4 of a four-part series, covering the journey from setting up Advanced Event Mesh to consuming Event APIs through Developer Hub:Part 1: Enabling Advanced Event Mesh for API ManagementPart 2: Connecting Advanced Event Mesh and Developer HubPart 3: Publishing event APIs on Developer Hub and managing API ProductsPart 4: Discover and consume Event APIs from SAP Developer HubYou don’t need to have followed the previous parts to complete this tutorial. In this part, we’ll take the perspective of a developer using Developer Hub: we’ll discover an Event API Product, subscribe to it, retrieve the required credentials, and use them to connect to the Event Broker and consume events.We’ll cover the following:Before you start (prerequisites):Be onboarded as an Application Developer in the Developer Hub.Have access to a client where you can test the connectivity to the Event Broker, in this example I’m using the “Try Me!” in SAP Integration Suite, Advanced Event MeshOptionally: Have viewing rights to the Event Portal and Application Domain in your Advanced Event Mesh environmentEvent API Products: Discover and Subscribe Go to the home page of the Developer Hub and go to your API Product containing event APIs. Under “Events”, you see an overview of the event APIs that are part of this product. “Rate Plan” gives you details on the rate plan that is linked to it the event API Product (defines messaging type, access type, queue type, etc.), “Associated Subscriptions” list which applications are subscribed to this Event API Product. Feel free to browse these different tabs.Now, let’s subscribe to the Event API Product, click on the button “Subscribe” on the right top and create the application (either create a new subscription or add it to an existing API application). If you’re creating a new API Application, enter a name (e.g. Sales Order Application) and optionally a short text and a description and press “Create”.  Once you created the application, you will be automatically redirected to the application. Later, you can find the application in the Developer Hub under “My Workspace”. In the application, you will find the credentials you can use to authenticate to the event broker/event API. “Key” will serve as your username and “Secret” as your password. For this tutorial, copy these credentials.  When consuming events using guaranteed messaging, the application consumes them from a queue. This allows messages to be stored on Advanced Event Mesh if the application is temporarily unavailable or cannot process messages as quickly as they are generated. In this case, you will also need the name of your queue, you find this in your application by going to “Products”, select your Event API Product, under “Queue Details” you find the name of your queue. Also copy the name of the queue for this tutorial. Optionally: if you have access to the event portal in Advanced Event Mesh (optional), you will see that after the creation of an application in the Developer Hub a new application is created in your Application Domain. Event APIs: Publishing and ConsumingFor publishing events to and/or consuming events from Event APIs using your credentials from the Developer Hub, you can use any client as long as you are able to specifcy the following:Broker URL (e.g.  https://mr-connection-xxxxx.messaging.solace.cloud:9443)Message VPN Client Username (key copied from Developer Hub)Client Password (secret copied from Developer Hub)Queue Name (name copied from Developer Hub)Topic (found in the Async API spec on the Developer Hub)Make sure your Queue Name and Topic are in line with the documentation. The key and secret provided are only whitelisted for the topics and queues that are part of the Event API Products in your API Application. If you try to subscribe or publish to a topic that is not included in the API Product, the operation will fail.⚠️If you don’t know which Broker URL or Message VPN should be used, reach out to one of your administrators in SAP Integration Suite, advanced event mesh.To demonstrate how the connection works, I will use “Try Me!” in Advanced Event Mesh. In SAP Integration Suite, advanced event mesh, go to “Cluster Manager” ➡️ select your Broker Service ➡️ click on “Try Me!” and at the left bottom of the page, hit “Open Broker Manager”.In “Try Me!”, enter the following under “Publisher”:Broker URL (e.g.  https://mr-connection-xxxxx.messaging.solace.cloud:9443)Message VPN Client Username (key copied from Developer Hub)Client Password (secret copied from Developer Hub)Make sure under “Subscriber” you checked “✅ Same as Publisher”Hit “Connect” at both the “Publisher” as the “Subscriber” side.You should now see the word “Connected” under “Establish Connections”.  Once the connection is established, scroll down to “Bind to an endpoint to receive guaranteed messages” on the “Subscriber” side:Select “Queue”Enter the queue name copied from the Developer HubHit “Start Consume”You should now see that the consumer is active If you were able to subscribe to the queue, scroll down to “Publish to topic” on the “Publisher” side:Enter the topic you want to publish on (needs to be part of an Event API Product where your API Application is subscribed to)Delivery Mode can remain “Direct”Enter a payload under “Message Content”Hit “Publish”After publishing events on the topic, you should see the messages appearing on the right side of the page (under “Subscriber”). This means that the messages are successfully being published on the topic and landing in the queue, using the credentials generated by creating an API Application.  What’s next You’ve now seen how developers can discover, subscribe to, and consume Event APIs through SAP Developer Hub using a self-service approach.This concludes our journey from setting up Advanced Event Mesh to enabling a self-service experience for developers to consume Event APIs through Developer Hub.If you want to see the complete picture and how the different pieces fit together, head back to the main blog, which provides an overview of the full series. Read More Technology Blog Posts by SAP articles 

#SAPCHANNEL

By ali

Leave a Reply