How to register GenericRequestClient in MassTransit using Autofac

480 views Asked by At

I am using MassTransit and need to work with Request/Response flow. I am also using Autofac to register all MassTransit stuff like this:

builder.AddMassTransit(cfg =>
        {
            // Consumers
            cfg.AddConsumers(ThisAssembly);

            // Bus
            cfg.UsingRabbitMq((context, c) =>
            {
               ...
               c.ReceiveEndpoint(settings.QueueName, e =>
               {
                  ...
                  e.ConfigureConsumers(context);
               }
            }
        });

I read in the documentation that I have to register IRequestClient<> like this:

cfg.AddRequestClient<CheckOrderStatus>();

But I am not having only one RequestClient but will have many of them, and want to register them automatically using Autofac.

There is something as x.AddGenericRequestClient() but it only works if using Microsoft DI container, and when I try to copy the behaviour of this extension into Autofac it does not work becauseit says that the ScopedConsumeContextProvider is not registered...

So how to register multiple RequestClients that can be in multiple assemblies into Autofac?

0

There are 0 answers