Search code examples
masstransit

MassTransit Kafka Add producer at runtime


Is there any way we can add a producer from our controller dynamically. We get the topic name at runtime and would need to add this using rider.AddProducer<ClassA,ClassB>() and then retrieve its instance using GetRequiredService<ITopicProducer<ClassA,ClassB>>(). I have gone through the documentation and this question, but couldn't find the answer. Kafka Producer with MassTransit - IBusInstance has not been registered


Solution

  • There isn't currently a way to add Kafka topic producers dynamically – they must be declared during rider configuration.

    This seems like a reasonable feature request, you could submit one here.