Reputation: 35
I have a particular use cases were my application, on startup, needs to generate a temporary queue, let messages accumulate while initializing, and only after initialization is completed start a consumer to this temporary queue.
The best option would be to create the queues still as auto-delete, but not start a consumer on them yet, and then attach a consumer later on after some initialization work is completed.
is this even possible with MassTransit ?
I cannot find a way to be able to do this with MassTransit and .net core. This is an example of the code i am using :
` serviceCollection.AddMassTransit(busConfigurator => { busConfigurator.AddConsumer();
busConfigurator.UsingRabbitMq((ctx, cfg) =>
{
cfg.Host("rabbitmq://localhost");
cfg.ReceiveEndpoint(queue =>
{
queue.ConfigureConsumer<MyConsumer>(ctx);
});
});
});`
as soon as the application starts, the consumer starts consuming messages, and i have no control over this. I also tried working with the IBusControl interface but stopping it will also remove the queues (of course, since they are vreated as auto-delete) .
Upvotes: 0
Views: 304
Reputation: 33540
You can use endpoint dependencies to block the receive endpoint from starting until you're ready for messages to be consumed.
Upvotes: 0