0

While using the NServiceBus Scheduler I have been unsuccessful in triggering the delegate defined. I used the documentation at the link below to setup the EndpointScheduler class.

The endpoints corresponding timeout queue is created and a message successfully enters the queue. No errors are encountered during execution, but the scheduler does not trigger the delegate. I am currently using NServiceBus 5.2.14, a similar test works using NServiceBus 3.2.7. Any ideas why the Scheduler isn't triggering the delegate?

http://docs.particular.net/nservicebus/scheduling/

public class EndpointScheduler : IWantToRunWhenBusStartsAndStops, ILoggable
{
    public EndpointScheduler(Schedule schedule)
    {
        this.schedule = schedule;
    }
    public void Start()
    {
        schedule.Every(
            TimeSpan.FromMinutes(1), 
            "Test", 
            () =>
            {
                Debug.WriteLine("I'm testing the scheduler");
            }
        );
    }           
    public void Stop()
    {
    }
}
Pietro
  • 43
  • 5
  • 1
    Well, unfortunately it just Works On My Machine™. Debug.WriteLine doesn't output to the console, but does show up in the Visual Studio output window. Console.WriteLine works to the console. I also see INFO messages logged before and after the task and can hit a breakpoint on it. I assume your example is missing a private `schedule` var otherwise it wouldn't compile. What is ILoggable, as that is not from NSB. Could that have anything to do with it? Otherwise, show your endpoint configuration code. Sure that TimeoutManager and TimeoutManagerBasedDeferral features are enabled? – David Boike Jul 21 '16 at 19:04
  • @DavidBoike This was completely caused by me. My EndpointConfig had this configuration DisableFeature(); Removing it corrected my mistake. Thanks for taking a look at this! – Pietro Jul 22 '16 at 12:34

1 Answers1

1

Thanks to @DavidBoike for pointing out a few potential setup issues.

The endpoint configuration contained:

configuration.DisableFeature<TimeoutManager>()

Removing it corrected the issue I encountered.

The reason for this is that the scheduler is dependent upon the TimeoutManager. It works by deferring a message to be processed later (using the TimeoutManager) and when that message is received, the delegate is invoked. Without the TimeoutManager activated, this can't work.

David Boike
  • 18,545
  • 7
  • 59
  • 94
Pietro
  • 43
  • 5