Catalin
Catalin

Reputation: 11731

Azure Service Bus Queue grouped messages

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)

Upvotes: 0

Views: 1973

Answers (2)

Kepar
Kepar

Reputation: 45

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.

Upvotes: 0

kspearrin
kspearrin

Reputation: 10788

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.

Upvotes: 1

Related Questions