I have two consumers one that gets data from bus 1, and it will then publis to Bus 2. I followed the instructions to use multibus in :https://masstransit.io/documentation/configuration/multibus#multibus-configuration
I set up ISecondbus interface as per link and configure mySecondConsumer:
container.AddMassTransit<ISecondBus>(x =>
{
x.AddConsumers(typeof(mySecondConsumer).Assembly);
x.AddBus(context => Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.Host(new Uri(busOptions.ConnectionString));
cfg.ReceiveEndpoint(_env.EnvironmentName.ToLower() + "-my-queue", ec =>
{
ec.ConfigureConsumer<mySecondConsumer>(context);
ec.UseScheduledRedelivery(r => r.Intervals(TimeSpan.FromMinutes(1),
TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(10)));
ec.UseMessageRetry(r => r.Immediate(5));
});
}));
});
In myfirstConsumer(which publishes to mySecondConsumer) i inject it in like this :
public myfirstConsumer(
Bind<ISecondBus, IPublishEndpoint> publishEndpoint,
ILogger<myfirstConsumer> logger,)
{
_publishEndpoint = publishEndpoint;
_logger = logger;
}
When i run it autofac throws an exception
---> (Inner Exception #1) Autofac.Core.DependencyResolutionException: An exception was thrown while activating DMS.Service.Documents.Consumer.DocumentBridgeUpdateRecievedConsumer.
2024-01-22 19:11:39 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Service.Documents.Consumer.myfirstConsumer' can be invoked with the available services and parameters:
2024-01-22 19:11:39 Cannot resolve parameter 'MassTransit.ExtensionsDependencyInjectionIntegration.Bind2[Common.Store.ISecondBus,MassTransit.IPublishEndpoint] publishEndpoint' of constructor 'Void .ctor(MassTransit.ExtensionsDependencyInjectionIntegration.Bind2[DMS.Common.Store.ISecondBus,MassTransit.IPublishEndpoint], Microsoft.Extensions.Logging.ILogger`1[DMS.Service.Documents.Consumer.DocumentBridgeUpdateRecievedConsumer])'.
It looks like it doesnt like the way i inject the Bind<ISecondBus, IPublishEndpoint> publishEndpoint.
Not sure what i can do?
How can i configure and call my Secondbus in MassTransit using Autofac