Reputation: 1284
Looking into examples of priority queues online it seems the standard is that the publisher sets the priority of the message. This makes sense if the message itself has meaning that dictates that "Fire detected!".
What if the priority is more dictated by the consumer? my scenario is this, I have 100s of customers generating messages, customer A wants me to have a dedicated message consumer for their messages. I don't want to have to change all my producers everytime this scenario comes into play. (perhaps they stop paying, perhaps someone else wants this also, perhaps we use this as a way of relieving some devops issues...)
Is there a way I could do this? Could the consumer "scan" all messages in a queue and "pass" on handling a message?
Upvotes: 1
Views: 170
Reputation: 18628
There no way, really, for Rebus to be able to "scan" messages or in any other way know beforehand which messages are available in order to pick one to handle.
Generally, with message queues, you just get the next message when you receive one.
If you need some kind of intelligence in how messages are picked when they need to be handled (and it sounds like that to me), I suggest you just handle messages by queueing them up as "work items" in a database, and then you periodically or continually pick the next work item to work on.
This way, your worker can perform arbitrarily complex logic when it picks the next work item - e.g. by skipping those that did not pay, ordering by customer plan (e.g. prioritizing "gold customers" over "silver customers"), etc.
This would have the added advantage IMO that it would make it a more prominent part of the application's logic, which I feel would be nice in this case.
Does that sound reasonable?
Upvotes: 1