Custom DataBus Serialiazer with Existing Container

NServiceBus 7.3.0
NServiceBus.Extensions.DependencyInjection 1.0.1

It’s not clear from the docs


and https://docs.particular.net/samples/databus/custom-serializer/ the correct approach for using a custom data bus serializer with an existing container.

I’m using StructureMap via Microsoft DependencyInjection and have tried adding the registration registry.For<IDataBusSerializer>().Use<JsonDataBusSerializer>(); to the registry from which I create a StructureMapServiceProviderFactory to pass to EndpointConfig.UseContainer. This doesn’t seem to be enough though - I also need to add endpointConfig.RegisterComponents(x => x.ConfigureComponent<JsonDataBusSerializer>(DependencyLifecycle.SingleInstance)); but that feels like I’m mixing two DI approaches?

Have I got something wrong here? Thanks in advance.

Ping!

Is my explanation of the situation not clear enough here?

Hi @simonfox,

Looking at the example provided, it does seem like something is off here.
I am looking into the problem and will keep you updated.

Kind regards,
Laila

1 Like

Hi @simonfox,

I was able to reproduce the issue by modifying one of our samples.
It should indeed be sufficient to register the custom serializer in the container you’re passing to the endpoint configuration.

I have raised an issue for it here. Feel free to subscribe to the GitHub issue to stay up to date.

Kind regards,
Laila Bougria

1 Like