Call service.AddKakfa() multiple times #157
-
Hi All, Is there a way we can invoke service.AddKafka() multiple times with the same app? I tried to call this multiple times and looks like it does not resolve the instances properly after that, anyway I can achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @ravi-kotha, You can call AddKafka multiple times if your application has more than one ServiceCollection/ServiceProvider, but is not usual. Maybe you can achieve that by calling AddKafka just one time and call the AddProducer multiple times, like: services.AddKafkaFlowHostedService(kafka => kafka
.AddCluster(cluster => cluster
{
foreach(var producerCOnfig in producersConfig)
cluster.AddProducer(...)
})
); |
Beta Was this translation helpful? Give feedback.
Hi @ravi-kotha,
You can call AddKafka multiple times if your application has more than one ServiceCollection/ServiceProvider, but is not usual.
Maybe you can achieve that by calling AddKafka just one time and call the AddProducer multiple times, like: