We are using NServiceBus 5.2.14 hosted inside .Net 4.6.1 windows services. We have added NServiceBus auditing to our services via the AuditConfig:
<AuditConfig QueueName="AuditService" />
When we turned on Auditing for the windows service containing our Sagas, we noticed some new subscriptions added to our subscriptions Sql table. Like these:
SubscriberEndpoint MessageType
ServiceThatIsPublishingEventTypeA@MyMachine MyAssembly.MessageTypeA,1.0.147.0
AuditService@MyMachine MyAssembly.MessageTypeA,1.0.147.0
It seems that after enabling auditing on the Saga service, the service that is publishing an event (that the saga is subscribing to), now gets a recursive subscription to itself.
When a message is processed, a copy is successfully pushed to the audit queue.
However, the problem I am having is that I also get a copy of the message pushed into the ServiceThatIsPublishingEventTypeA.Error queue and an exception raised in my log.
The exception is:
System.InvalidOperationException: No handlers could be found for message type: MyAssembly.MessageTypeA
at NServiceBus.LoadHandlersBehavior.Invoke(IncomingContext context, Action next) in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Unicast\Behaviors\LoadHandlersBehavior.cs:line 29
at NServiceBus.BehaviorChain`1.InvokeNext(T context) in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 107
at NServiceBus.BehaviorChain`1.<>c__DisplayClass4_0.<InvokeNext>b__0() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 94
This makes sense as there are no handlers for MyAssembly.MessageTypeA event within ServiceThatIsPublishingEventTypeA service (it just publishes these events), yet the auditing has added this subscription.
So my question is: Is that recursive subscription correct? what is the correct way to audit the traffic through a saga (and avoid the errors being raised)?
Thanks for your help
I'm guessing the endpoint is auto subscribing to the events it finds in assembly scanning, can you try and disable auto subscribe?
== EDIT
After looking at the code on github i created a pull request with a version that works, the main issue was that the audit component was processing subscription messages it received via the audit channel...
I also cleaned up some minor redundant code