Fork me on GitHub

Delayed Messages Edit on GitHub


All DateTime's are converted to UTC dates behind the scenes before transmitting through any transport channel. The successor to FubuMVC will likely change the API to use DataTimeOffset's

Sometimes you will need to send a message, but request that it be executed at a later time. For that purpose, FubuMVC exposes the "delayed messages" functionality demonstrated below:


public class DelayedMessageSender
{
    public void SendDelayedMessage(IServiceBus bus)
    {
        // Send the DoLaterMessage, but delay the processing until
        // the start of the day 5 days from now
        bus.DelaySend(new DoLaterMessage(), DateTime.Today.AddDays(5));



        // Send the DoLaterMessage, but delay the processing for an
        // hour
        bus.DelaySend(new DoLaterMessage(), TimeSpan.FromHours(1));
    }
}

In the sample above, we're sending a DoLaterMessage to the bus. Behind the scenes, FubuMVC is

  1. Selecting the proper channels to send the message to based on the normal routing rules
  2. Adding a header value for "time-to-send" to the outgoing envelope that will tell the receiver when the message should be processed
  3. When the receiving node sees the new message with a "time-to-send" header value, it takes that message and places it into local storage
  4. An internal polling job in FubuMVC (the "DelayedEnvelopeProcessor") checks for delayed messages that are ready to process according to the system clock and executes them locally