On the documentation for confluent kafka's dotnet producers the given example is like this:
using Confluent.Kafka;
using System.Net;
...
var config = new ProducerConfig
{
BootstrapServers = "host1:9092,host2:9092",
ClientId = Dns.GetHostName(),
...
};
using (var producer = new ProducerBuilder<Null, string>(config).Build())
{
...
}
Why do we create and dispose of the producer, over creating it once and injecting it?
question from:
https://stackoverflow.com/questions/65952470/why-are-producers-immediately-disposed-after-use 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…