The objective of this DEMO is to showcase the difference in how to integrate Service Bus and Event Hub using an SDK. In addition, we will explore how Logic App can integrate with both the messaging services.
- Clone the repository
- Install the Azure Event Hubs client library using npm
cd event-hub
npm install
- Install the Azure Service Bus client library using npm
cd service-bus
npm install
As you can notice from the content of the folder "service-bus/topic/" you can find two receivers. Each receiver is associated two a different subscription. The best way to explore this concept is to create two subscription and a filter read this introduction: Topic filters and actions
This is an snapshot of the one used in this DEMO:
Please read carefully the following guides:
- Event Hubs SDK and the reference guide
- Service Bus SDK and the reference guide
You should now create the connection strings associated to the Event Hub and Service Bus that you created and copy paste it in the relevant files"
/service-bus/topic/sendTopic.js
/service-bus/topic/receivefromsubscriptionAll.js
/service-bus/topic/receivefromsubscriptionRecent.js
/event-hub/event-hub-send.js
/event-hub/event-hub-receive.js
In each of those file, you will find variables at the top of the files where you need to copy paste the connection string.
In this section we will create a Logic App with the following logic:
- Please create a HTTP request trigger Logic App. You can follow this example. The message payload that you can use to generate the payload is the following:
{
"isEvent" : "Y",
"body": "Galileo"
}
-
After the HTTP trigger, please create a condition with this basic logic:
-
In this step, you should create the Service Bus and Event Hub action to send message in the respective queues. Please check the images and the guides below:
**** Integrate Logic app with Event Hubs Integrate Logic app with Service Bus
-
In the last step you should provide a response to your client:
The overall flow should be the following:
You can test the service-bus with the following commands:
cd /service-bus/topic
node receivefromsubscriptionAll.js
node sendTopic.js
You can test the event-hub with the following commands:
cd /event-hub
node event-hub-receive.js
node event-hub-send.js
If you want to test the overall integration, you can use postman. Select the Method POST and as URL the Logic App url. The request body should be set to JSON and you can send the following content to trigger the Event Hub:
{
"isEvent" : "Y",
"body": "Galileo"
}
And the following content to trigger the Service Bus:
{
"isEvent" : "Y",
"body": "Galileo"
}