The scalability inherent in parallel message-driven systems
makes them more difficult to debug than their sequential,
synchronous and centralized counterparts.
For these reasons, NServiceBus provides message auditing
built-in to every endpoint. All you need to do is tell
NServiceBus where you want to send those messages.
In order to turn on auditing, all you have to do is to add the attribute "ForwardReceivedMessagesTo" to the UnicastBusConfig section of an endpoint's configuration file as shown below:
<!-- You can control the TimeToBeREceived on messages going to the audit queue --> <!-- by using the TimeToBeReceivedOnForwardedMessages setting --> <UnicastBusConfig ForwardReceivedMessagesTo="AuditQueue@AdminMachine" > <MessageEndpointMappings> <!-- rest of your configuration here --> </MessageEndpointMappings> </UnicastBusConfig>
The above configuration will cause all messages arriving at the given endpoint to be forwarded to the queue called "AuditQueue" on the machine called "AdminMachine". You can specify any queue on any machine, though only one is supported. Of course, you can forward on from that machines as well.
What you choose to do with those messages is now up to you - you can save them in a database, do some custom logging, anything.
The important thing is that you now have a centralized record of everything that's happening in your system while maintaining all the benefits of keep things distributed.
On each message there are some custom headers attached that you can look at using a 3rd party tool for MSMQ.
|NServiceBus.Version||Version of NServiceBus|
|NServiceBus.TimeSent||When was the message sent|
|NServiceBus.EnclosedMessageTypes||Massage type(s) within the envelope|
|NServiceBus.ProcessingStarted||Time when processing of the message started|
|NServiceBus.ProcessingEnded||Time when the processing was finished|
|NServiceBus.OriginatingAddress||From where did the envelope originate|
Learn more about how logging works in NServiceBus.