Skip to content
jefking edited this page Nov 27, 2014 · 2 revisions

Use Case

When you need an action to occur at a specific time. This is a great way to control the timing of operations and control the time of execution.

Resolution

Resolution is the ~millisecond under normal operation, timing can change when Service Bus queue is under load, or failures are occurring.

In order to make this happen, the message is dequeued seconds before the server will take action. When the message is dequeued, the thread is put to sleep and wakes up near to the time when work is to be done. The actual time your code will receive execution will always be after the time you specified.

Note: You must be scheduling for at least 5 seconds in the future.

Classes

Setup is quite simple, you need to be working off the same queue for sending and recieving; and have the same object/data sent and defined to be picked up. The work to ensure that the timing is correct is handled for you, and all you need to do is supply an IProcessor<Model> which will handle the data that was shipped.

Queue to Buffer Place code where you want to pass to the queue, the DateTime parameter is the time at which you want the work done.

var queue = new BusQueueSender("Name", "Connection String");
await queue.SendBuffered(model, DateTime.UtcNow.AddSeconds(30));

Capture Events The receiver should be loaded on your Worker Role, using the King.Service factory.

var queue = new BusQueueReciever("Name", "Connection String");
new BufferedReciever<Model>(queue, new EventHandler())
Clone this wiki locally