Why Is It Not Recommended to Use a Sarama Client for Messaging?
Symptom
If a Sarama client is used to send and receive messages, the following issues may occur:
- Sarama cannot detect partition changes. Adding topic partitions requires client restart to enable consumption.
- Sarama's default MaxProcessingTime is 100 ms. When this limit is reached, consumers can no longer consume messages.
- If consumer offsets reset from the oldest (earliest) position, all messages starting from the earliest position may be repeatedly consumed after the client restarts.
- A consumer that subscribes to multiple topics may not be able to consume any message from specific partitions.
Solution
Use confluent-kafka-go as the Kafka client library.
For details, see Table 1.
| Client | Pros | Cons |
|---|---|---|
| confluent-kafka-go |
| High compiling complexity because Go compilers need extra resources to configure the imported C++ libraries |
| Kafka-go |
|
|
| Sarama | Better asynchronization and higher concurrency (written in the original Go language) |
|
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.