I Have one Consumer-A, and i want to create multimple endpoints witj this consumer. For companies that can be added at runtime. Each company should have its own queue. Is it possible to do with MassTransit InMemmory?
Must be something like this
Consumer-A(with SomeID-a)
Consumer-A(with SomeID-b)
and many other..
And when I sent a message to the queue it was processed by the exact consumer (only 1 concurrent)
I`ve tried this
await using var provider = new ServiceCollection()
.AddMassTransit(x =>
{
x.AddConsumer<ConsumerServiceA>()
.Endpoint(e =>
{
e.Name = "endpint-service";
e.Temporary = false;
e.ConcurrentMessageLimit = 1;
e.InstanceId = SomeId-a;
});
})
.BuildServiceProvider();
I run it when new company created
I solved it by this
var consumer = new ConsumerA();
_bus = Bus.Factory.CreateUsingInMemory(cfg =>
{
cfg.ConcurrentMessageLimit = 1;
});
_bus.ConnectReceiveEndpoint("queue-a", x =>
{
x.Consumer(() => consumer);
});