Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NServiceBus message handler not going to 'error' queue on exception

I have a sample NServiceBus application to test the waters.. All is going well, sending and handling is working correctly.

I have deliberately thrown an exception within a certain message handler to see what happens - but nothing does. The exception is logged correctly to the console, yet the message is pulled off the queue and NOT placed in the error queue as I'd expect. Also, the 5 times retry didn't occur either. Is this correct behaviour?

Also, the queue was created correctly at startup when first specified.

the config and bootstrap code for the server (where the handler resides are below)

config:

<MsmqTransportConfig
  InputQueue="SiteServer1"
  NumberOfWorkerThreads="1"
  MaxRetries="5"
  ErrorQueue="SiteServer1Errors"
/>

program.cs:

var bus = NServiceBus.Configure.With()
  .Log4Net()
  .CastleWindsorBuilder(container)
  .XmlSerializer()
  .MsmqTransport()
  .UnicastBus()
    .LoadMessageHandlers()
  .CreateBus()
  .Start();

Am I missing anything here?

like image 617
Ben Laan Avatar asked Aug 03 '11 15:08

Ben Laan


2 Answers

I modified the bootstrapper code to include

.IsTransactional(true)

on the bus config and now it is working! It seems that non-transactional messages are disposable. Makes sense!

like image 131
Ben Laan Avatar answered Sep 19 '22 14:09

Ben Laan


Are you running Windows Server 2008? If so you will find an event log in the event viewer, under the Application event logs -> windows -> MSMQ - End2End. This will record every action taken by the MSMQ subsystem on your machine.

I am guessing that NSB has tried to send the message to the error queue. However, what is really hapenning is that the MSMQ subsystem on your machine has consumed the message, but not been able to deliver it to the error queue for some reason.

I would look in the MSMQ log for an idea of what is going on.

like image 28
tom redfern Avatar answered Sep 19 '22 14:09

tom redfern