Confluent-kafka-dotnet: Question: Producer Usage

Created on 26 Apr 2017  路  1Comment  路  Source: confluentinc/confluent-kafka-dotnet

Regarding the usage of the Producer, what is the recommended way to set it up.

  1. Create a Producer instance per topic
  2. Create a single Producer instance and send all messages for all topics to that one.

I can see the API design allows us to use the same Producer instance to send messages to any topics, but I'm not sure if there are any differences like performance or functionality differences under the hood between the two ways.

Tried to search around but missed if this was asked/discussed before.

I suppose similar question can be asked about the Consumer since it can subscribe to multiple topics as well.

question

Most helpful comment

2) is the correct way
All producer are independant. So creating multiple producer will create multiple connexions to brokers, and won't send messages in batch automatically (what librdkafka do internally)

If you use serialization, you should create one Producer and then use GetSerializingProducer to get an ISerializingProducer.

For most question about usage/performance, you can also take a loot at edenhill/librdkafka (The C library Confluent.Kafka wrapped)

>All comments

2) is the correct way
All producer are independant. So creating multiple producer will create multiple connexions to brokers, and won't send messages in batch automatically (what librdkafka do internally)

If you use serialization, you should create one Producer and then use GetSerializingProducer to get an ISerializingProducer.

For most question about usage/performance, you can also take a loot at edenhill/librdkafka (The C library Confluent.Kafka wrapped)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeffreycruzana picture jeffreycruzana  路  3Comments

andreas-soroko picture andreas-soroko  路  3Comments

farodin91 picture farodin91  路  3Comments

Marusyk picture Marusyk  路  3Comments

MihaiComan87 picture MihaiComan87  路  3Comments