Reputation: 458
I'm trying to figure out if rebus supports querying of the queue. I want to peek in the queue, to find out if a message is already on the queue in a deferred state. the reason is that we are doing a fairly expensive operation that we want executed once a day and we may have multiple instances of a service, so we want to make sure that we only have on message of this type on the bus.
Is this possible with rebus or should i use the azure service bus api for this?
Upvotes: 2
Views: 281
Reputation: 18628
It's not possible with Rebus :(
To me it sounds more like you want to use some kind of scheduler, e.g. like Quartz .NET, or maybe something you code yourself.
Querying the Azure Service Bus queue sounds like a bad idea to me, because it's kind of backwards, considering that it sounds like you simply want to execute some task daily.
This would suddenly tie you to the ASB transport and its quirks, also tying yourself to the fact that Rebus' deferred messages are implemented using the delayed visibility feature of ASB, thus making your code less portable.
Lastly, I fear that you would run into concurrency issues, because it would not be trivial to avoid race conditions around who gets to put the deferred message into the queue.
If I were you I would code a simple scheduling thing myself, and then have it send Rebus messages periodically as needed.
Upvotes: 2