2

I'm using the code created from the offical NserviceBus Walk through, I'm trying to send a message from with the Schedule action

public class SendOrder : IWantToRunWhenBusStartsAndStops
{
    public IBus Bus { get; set; }
    public Schedule _schedule;

    public SendOrder(Schedule schedule)
    {
        _schedule = schedule;
    }

    public void Start()
    {
        _schedule.Every(TimeSpan.FromSeconds(5),() =>
        {
            Bus.Send("Ordering.Server", new PlaceOrder {Id = Guid.NewGuid()});
            Console.WriteLine("Sent a message.");
        });
    }

    public void Stop()
    {
    }
}

But I get an error that I Don't understand why it would be calling out the Timeouts queue. When Invoking the Bus.Send that is not in the Schedule action it works fine.

The destination queue 'Ordering.Client.Timeouts@Z220-STATION1' could not be found. You may have misconfigured the destination for this kind of message (NServiceBus.Scheduling.Messages.ScheduledTask, NServiceBus.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c) in the MessageEndpointMappings of the UnicastBusConfig section in your configuration file. It may also be the case that the given queue just hasn't been created yet, or has been deleted.

Any help will be great!

  • Solved.... It seems like the endpoint needs to be configured to include AsA_Server to create the queue automatically in msmq. – Pragmatic boy Jan 22 '15 at 11:12

1 Answers1

0

To answer your question - NServiceBus scheduling works by sending timeout messages to the future. When timeout message arrives, it calls your delegate and sends another timeout.

This is why you must have a timeout queue.

NServiceBus creates queues automatically when executed in development profile. This does not happen in production. You should either run nservicebus.host.exe /install if you use NServiceBus hosting, or initialize installers in your code like this, if you run self-hosted:

Bus = Configure.With()
.Log4Net()
.DefaultBuilder()
.XmlSerializer()
.MsmqTransport()
.IsTransactional(false)
.PurgeOnStartup(false)
.UnicastBus()
.ImpersonateSender(false)
.CreateBus()
.Start(() => Configure.Instance.ForInstallationOn<Windows>().Install());

As described here

The last line starts the bus and asks the startup code to run the delegate, where you force installers to run.

Community
  • 1
  • 1
Alexey Zimarev
  • 17,944
  • 2
  • 55
  • 83