No handlers could be found for message type after upgrade to NServiceBus 7.5 (.NET 5.0)

Hi,
I’m currently upgrading my microservices from:

.NET 3.1 to .NET 5.0
NServiceBus 7.2.0 to NServiceBus 7.5
NServiceBus.AmazonSQS 4.3.5 to 5.4.0
NServiceBus.Persistence.Sql 4.6.1 to 6.2.0

The microservices are completely event driven and each microservice starts its own endpoint. Before the upgrade we were using the Amazon SQS transport to register the publishers like this:

var routing = sqsTransport.Routing();
routing.RegisterPublisher(eventType, endpoint);

After the upgrade and deployment, I am facing the following issues:

The service’s endpoint starts fine. But upon receiving an event msg from another service, the following exception is thrown and the msg ends up in the error queue:

System.InvalidOperationException: No handlers could be found for message type: ServiceK.CardNumberUpdatedEvent

Second issue is that the subscriber services are no longer sending the Subscribe message to the publisher services.
As per the article: Upgrade AmazonSQS Transport Version 4 to 5 • Amazon SQS Transport • Particular Docs, I then changed the code to register the publishers like this:

var pubSubCompatibilityMode = sqsTransport.EnableMessageDrivenPubSubCompatibilityMode();
pubSubCompatibilityMode.RegisterPublisher(....)

Third issue is that even with enabling message driven pubsub compatibility mode, the Native Publish/Subscribe doesn’t work. I don’t see any SNS topics getting created in AWS. I also checked the Cloud Trail event history; I only see CreateQueue events. And don’t see any CreateTopic events.

Am I missing something here?

Hey @omair.shakeel

The service’s endpoint starts fine. But upon receiving an event msg from another service, the following exception is thrown and the msg ends up in the error queue […]

Are your handles located in a separate assembly that is loaded with the endpoint or are they defined as part of the endpoint?

Second issue is that the subscriber services are no longer sending the Subscribe message to the publisher services.

I don’t see any SNS topics getting created in AWS.

It does sound like the event types are not correctly recognized and therefore the auto-subscriptions feature does not do any setup. Can you configure your logging to log in debug level and share the logs of the endpoint start along with the startup diagnostic file with me? You can send me these two files via a direct message.

Thanks @Tim

My message handlers are located in a separate assembly. The assembly that starts the endpoint is a common assembly used by all of our microservices.
So we have these projects:
Common.NServiceBus => configures the endpoint, SQS transport and starts the endpoint
ServiceA.NServiceBus => refers the Common.NServiceBus and contains the message handlers
ServiceA.Worker (executable) => refers to ServiceA.NServiceBus & Common.NServiceBus

I have turned on debug logging and also generated a startup diagnostic file.
How do I send you a direct message? I couldn’t find any option to do so.

Thanks, Omair

Thanks for gathering the files Omair. I’ve sent you a direct message in discourse, you should be able to reply to this message. Please let me know in case that doesn’t work.

Got the issue resolved. The problem was with the Microsoft DI setup code that was explicitly calling:

services.AddSingleton(_ => new MessageHandlerRegistry());

This was messing up with the auto-subscribe feature. Removing this line of code above worked.

One interesting find. If you have set Recoverability() on your endpoint and are using NServiceBus.Serilog 7.0.0, then during message retry/recovery, the NServiceBus.SeriLog logs message: Failed to execute recoverability policy for message with native ID and with: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.DateTime'.

However, this problem went away after upgrading to NServiceBus.Serilog 7.16.0. Recoverability now works fine and failed messages get moved to the error queue.