0
votes

I have a web api application which performs different type of actions an a Domain entity, called Application. Actions like "Copy", "Update", "Recycle", "Restore" etc.

This actions needs to be executed, per Application, in First In First Out order, not randomly or simultaneous. However, it can process simultaneously two Actions as long as they are for two separate Applications.

Is some kind of a queue, but not a big queue for all the requests, but a queue of actions for each Application in database.

Knowing this, i think that azure service bus queue is a good solution for this scenario.

However, the solution i can think of right now is to programmatically create a queue for each Application i have in database, and start listening to that queue.

Is possible to get messages from the queue based on a filter? (using FIFO principle) So i have to subscribe only to one queue? (instead of having a queue for each Application - which is very hard to maintain)

2
Did I answer your question?kspearrin
@kspearrin thanks for the answer. I will have to do some tests and see if its working. From what i see, subscriptions allows me to filter the queues, but o don't have any filter criteria. I need only one subscription which receives the queues in chunks, based on their Application Id propertyCatalin
Unless I am misunderstanding you, you should create multiple subscriptions (for each application) to the topic which filter based on this Application Id header. Then just include the Application Id on every message published to the topic.kspearrin
This is what i was trying to avoid. Having a subscription per application is harder to manage, for example a subscription needs to be removed if the application is deleted. Or when the Web Server starts, i need to get all the applications ids and create a subscription for each of themCatalin

2 Answers

1
votes

What you want is Azure Service Bus Topics/Subscriptions.

Subscriptions allow you to filter messages that are published to a topic using a SqlFilter on the message headers.

The article linked above should provide enough examples to meet your needs.

0
votes

I think u can solve this by using Sessions.

I just came across this very clear article: https://dev.to/azure/ordered-queue-processing-in-azure-functions-4h6c which explains in to detail how Azure Service Bus Queue sessions work.

In short: by defining a SessionId on the messages you can force the ordering of the processing within a session, the downside is that there will be no parallelization for all messages in a session between multiple consumers of the queue.