6

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.

Slee
  • 27,498
  • 52
  • 145
  • 243

3 Answers3

9

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.

Abhishek Lal
  • 3,233
  • 1
  • 17
  • 16
2

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.

SoftwareFactor
  • 8,430
  • 3
  • 30
  • 34
0

You may use a polling mechanism utilizing receiveMessages() API in PEEK_LOCK mode in order to achieve filtering over queues and maintain a subscription to a flux stream of messages that pass your filter.

I have attempted to write a sample implementation in this project - Find GitHub Repo Here

Also, you can have a look at this article to understand its usage and scope.