sajid irfan
sajid irfan

Reputation: 387

Send messages to clients using Azure Service Bus - Topics

Using Azure Service Bus - Topics, I want to implement a solution wherein messages are sent/notified to end consumers once the producer sends the message to Topic (like Queues).

I understand that Topics work as Pub/Sub model wherein subscribers need to read messages from subscriptions. But I'm looking for a workaround that works some what similar to Queue (where it triggers a web job / service when any message is received).

I have few thoughts like 1. Using Auto-Forwarding in subscriptions to forward messages to Queues but again I think if this kills the purpose of Topics 2. Schedule a job to process these requests but again I think if I'm delaying the process

First, I want to know if Service Bus Topic is right option to go with? Next, If possible to implement a workaround what is the best/better way?

PS: I have to send messages which has information - I guess I can't use Relays

Upvotes: 1

Views: 2468

Answers (3)

Imran Arshad
Imran Arshad

Reputation: 4002

From discussion above.

Azure functions with Queues/Topics

Regardless of queues or topics. you can trigger azure function with both. This function will process the message . Now you can create two methods in same function SendEmail(), sendPhoneNotifcation() and parrellize the tasks using C# task parallel library. So same function will do both tasks in parallel.

Every time you get a message , your function is triggered. Process the message and notify user. The benefit is this function will scale automatically if you have large number of message coming through queue.

Upvotes: 0

Roberto Borges
Roberto Borges

Reputation: 793

I think that @William is right, you can use/attach other process to the subscription to make what you trying to do.

he mentioned Azure Functions which is a good tool and I want to suggest Azure Logic Apps as well in case you want to take some decisions based in the message that you received.

With Azure Logic Apps you can create a logic Workflow and integrate many services using connectors provided by this tool.

You will find more in:

https://learn.microsoft.com/en-us/azure/connectors/connectors-create-api-servicebus

And for answer your question

First, I want to know if Service Bus Topic is right option to go with?

The quick answer is yes, using messaging patterns is the best way to create reliable solutions.

In your case you want as well notify another system after receiving a message.

The only thing that you need to be aware is, whenever you did not receive the notification what you'll do? you need to think about this scenario.

Upvotes: 0

William Xifaras
William Xifaras

Reputation: 5312

Just to be clear, Queues and Topics in Service Bus are different. As you noted, Topics are useful in publish/subscribe scenarios.

Since you are looking for something that gets triggered, Azure functions might be what you need.

Azure Functions supports trigger and output bindings for Service Bus queues and topics

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus

Upvotes: 1

Related Questions