Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I filter Azure Service Bus Queue messages based on a message property?

I am using Azure Service Bus Queue to send emails out from my app. I have many different customers that send out emails via my app and each message gets a property that identifies that customer: CustomerID

I need to write an admin area for my customers to look at the pending message in the queue and more importantly see the deadletter queue. I do not want them to see everyones deadletters so I want to filter the messages based on the property CompanyID.

How do I accomplish this?

I read about topics and subscriptions but I add 10+ customers a week at least and this would not be a reasonable solution for me.

like image 515
Slee Avatar asked May 24 '14 12:05

Slee


People also ask

Does Service Bus queues support message filtering?

Service Bus supports three filter conditions: SQL Filters - A SqlFilter holds a SQL-like conditional expression that is evaluated in the broker against the arriving messages' user-defined properties and system properties. All system properties must be prefixed with sys.

How do I filter messages in Service Bus Explorer?

Configure the filter for the ServiceBus subscription You can set the “Default Filter” when you create a new subscription in Azure ServiceBus Explorer. If you want to change an existing filter, expand the subscription, expand the rules, delete the existing $Default rule and add a new one with your filter expression.

How do I check messages on Azure Service Bus queue?

To peek messages, select Peek Mode in the Service Bus Explorer dropdown. Check the metrics to see if there are Active Messages or Dead-lettered Messages to peek and select either Queue / Subscription or DeadLetter sub-queue. Select the Peek from start button.


2 Answers

Queues do not support Filtering. You can write admin clients that get all messages and filter on the client end but consider Topics/Subscriptions because you can easily add up to 2000 Subscriptions per Topic and then filter messages in these by Customer etc. For things that you want to Query repeatedly on an approach as the one mentioned above, where you have a daemon parse the queue and update a table and then each customer runs queries on that status table would work better.

like image 176
Abhishek Lal Avatar answered Nov 15 '22 04:11

Abhishek Lal


Queues are generally not a good fit for querying and advanced filtering scenarios. Peeking through a large queue when a customer checks for status would defeat the whole purpose of using a service bus.

My suggestion is to store the status of started tasks in Azure table storage. Once worker role processes or fails processing a message in the queue, it could simply update the status in the table storage.

like image 37
SoftwareFactor Avatar answered Nov 15 '22 05:11

SoftwareFactor