1
votes

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

3
can you explain what exactly you are trying to achieve. topic/sub can do anything what you can do with queues. you can also trigger jobs with pub/sub. - Imran Arshad
@ImranArshad, I have two independent tasks to perform, 1. Send an email notification to users 2. Send an notification to user on their mobile app. One important thing over here is, this should complete within a minute so I don't think scheduler are appropriate in this case. Basically, I want to have a listener for my Topic/subscription/subscriptions - sajid irfan
yeah that can be achieved with your custom application subscribed to topic/subscription or better you can use serverless fucntions. which technology or services are you using? i can explain better if it's azure and .net core - Imran Arshad
@ImranArshad, yes, I want to use Azure and .net core. If Azure Functions are used that would be perfect. - sajid irfan

3 Answers

1
votes

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://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus

0
votes

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://docs.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.

0
votes

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.