O'Reilly logo

Learning NServiceBus by David Boike

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scheduling

By now you're probably thinking that Saga timeouts sound great, but what if you just need to run something on a schedule? Maybe you're thinking you'll create an IWantToRunWhenBusStartsAndStops class with a Timer. Well if you are, stop right there! NServiceBus can bring the power of timeouts to you without the full ceremony of a saga.

Schedule.Every(TimeSpan.FromMinutes(5)).Action(() =>
{
  Bus.Send<DoSomethingEvery5MinutesCmd>();
});

Schedule.Every(TimeSpan.FromMinutes(5)).Action("Task Name", () =>
{
  Bus.Send<DoNamedTaskEvery5MinutesCmd>();
});

With an NServiceBus scheduled task, you can count on the action happening no matter what, even if you schedule it to run every 24 hours and your IT manager reboots the server every 23 hours.

Generally, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required