NServiceBus - Server is throwing empty message war

2019-09-06 20:01发布

问题:

2013-03-28 10:18:32,374 [Worker.5] 
WARN  NServiceBus.Unicast.UnicastBus [(null)] <(null)> - 
Received an empty message - ignoring.

I have a client that bus.send("server", command) going from an mvc4 website to a message processor. The message processor was setup to be default without any custom initialization.

This is my configuration on the website side in the global.asax

        Configure.With()
            .StructureMapBuilder(container)
            .JsonSerializer()
            .Log4Net()
            .MsmqTransport()
                .IsTransactional(false)
                .PurgeOnStartup(true)
            .UnicastBus()
                .ImpersonateSender(false)
            .CreateBus()
            .Start(() => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());         

I reviewed NServicebus publishing event - recieves empty message, but that didn't help, I don't have read only properties.

回答1:

The problem is similar to the linked question in the OP. I found that the serialization methods need to match between the sender and the server. I had to add custom initialization on the server side and add the defaultbuilder as well as the json serializer to match the web side in order for messages to work right.



回答2:

One other thing which I found was, I was using IWantCustomInitialization with below configuration:

Configure.With(typeof(TransactionDetailsHandler).Assembly) // this is problematic one
                .CastleWindsorBuilder(container)
                .DefaultBuilder();

I didn't specify assembly type of my message in Configure. With adding that resolved the problem.