I was trying to schedule messages on service bus. I checkout the following link and it worked out well- https://medium.com/event-driven-utopia/azure-service-bus-essentials-scheduled-messages-98fd542f9d55
So we can Schedule ServiceBusMessage
Now what if I want to schedule ServiceBusMessageBatch
?
Is there any workaround?
When working with batches, assuming you're using ServiceBusMessageBatch
, you can't specify a scheduled enqueue time on the entire batch, but you can do so on each message. ServiceBusMessage
exposes a property called ScheduledEnqueueTime
. You can assign the same desired enqueue time for each message added to the batch (similar to what the blog post refers to as "Scheduling with send API"), and the final result will be all messages scheduled for the same time and showing up in the queue when it's time. I wouldn't consider this a workaround, though.
There are some nuances, such as what happens if you schedule a batch, but not all messages cannot fit in a single batch. For most scenarios, it won't be an issue, and I would discourage trying to get a scheduling precision down to seconds, but something to note.