You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When publishing using interface-defined events and when the messageConstructor not defined, an exception is thrown and the event is not published.
I came across an error situation which should have been a lot quicker to identify the root cause.
Using NServiceBus.Core 4.3.0 and NServiceBus.RabbitMQ 3.2.1
I have an event ITestEvent with one property. I'm also using Unobtrusive mode (have been for ages, this isn't a new message type).
If my commandhandler executes the following code it all works as expected:
but if my commandhandler executes the following code (forgetting to specify the messageConstructor for the event):
publicoverridevoidHandle(TestCommandcommand){
LogTo.Info("Processing a {0} command...", command.GetType().Name);
Bus.Publish<ITestEvent>();// oops, forgot to set the event properties}
then I get the following error log:
NServiceBus.Unicast.Transport.TransportReceiver - "Failed to process message" with exception
System.Exception: Could not find Metadata for 'System.Object'.
Please ensure the following:
1. 'System.Object' is included in initial scanning see File Scanning: http://particular.net/articles/the-nservicebus-host
2. 'System.Object' implements either 'IMessage', 'IEvent' or 'ICommand' or alternatively, if you don't want to implement an interface, you can use 'Unobtrusive Mode' see: http://particular.net/articles/unobtrusive-mode-messages
at NServiceBus.Unicast.Messages.MessageMetadataRegistry.GetMessageDefinition(Type messageType) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Messages\MessageMetadataRegistry.cs:line 18
at NServiceBus.Unicast.Messages.LogicalMessageFactory.<CreateMultiple>b__0(Object m) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Messages\LogicalMessageFactory.cs:line 53
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at NServiceBus.Unicast.Messages.LogicalMessageFactory.CreateMultiple(IEnumerable`1 messages) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Messages\LogicalMessageFactory.cs:line 48
at NServiceBus.Unicast.UnicastBus.Publish[T](T[] messages) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 305
at NServiceBus.Unicast.UnicastBus.Publish[T](T message) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 276
at NServiceBus.Unicast.UnicastBus.Publish[T](T[] messages) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 295
at NServiceBus.Unicast.UnicastBus.Publish[T]() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 284
at Xero.PostOffice.Test5.TestCommandHandler.Handle(TestCommand command) in c:\Dev\temp\Xero.PostOffice.Test5\Xero.PostOffice.Test5\TestCommandHandler.cs:line 19
at lambda_method(Closure , Object , Object )
at NServiceBus.Unicast.HandlerInvocationCache.Invoke(Object handler, Object message, Dictionary`2 dictionary) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\HandlerInvocationCache.cs:line 61
at NServiceBus.Unicast.HandlerInvocationCache.InvokeHandle(Object handler, Object message) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\HandlerInvocationCache.cs:line 22
at NServiceBus.Unicast.Behaviors.LoadHandlersBehavior.<Invoke>b__1(Object handlerInstance, Object message) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Behaviors\LoadHandlersBehavior.cs:line 38
SNIP
at NServiceBus.UnitOfWork.UnitOfWorkBehavior.Invoke(ReceivePhysicalMessageContext context, Action next) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\UnitOfWork\UnitOfWorkBehavior.cs:line 20
So two questions:
My ITestEvent should only ever be published when all its properties have been specified - is there a way to enforce this?
Regardless, the error message isn't at all helpful - the error isn't a bad inheritance chain or unobtrusive msg settings, it's that I forgot to set the event properties. The error message is misleading.
The text was updated successfully, but these errors were encountered:
When publishing using interface-defined events and when the messageConstructor not defined, an exception is thrown and the event is not published.
I came across an error situation which should have been a lot quicker to identify the root cause.
Using NServiceBus.Core 4.3.0 and NServiceBus.RabbitMQ 3.2.1
I have an event ITestEvent with one property. I'm also using Unobtrusive mode (have been for ages, this isn't a new message type).
If my commandhandler executes the following code it all works as expected:
but if my commandhandler executes the following code (forgetting to specify the messageConstructor for the event):
then I get the following error log:
So two questions:
The text was updated successfully, but these errors were encountered: