Problem description
When you use a Sarama Go client, the following issues may occur:
After you add a partition for a topic, the client may not detect the new partition or consume messages in the partition. You must restart the client to enable the client to consume messages from the new partition.
Many protocols of Sarama Go clients do not comply with the standards of the Apache Kafka community. When exceptions occur in a broker, the following issues may occur:
The OutOfRange mechanism may be triggered on the client. If the consumer offset reset policy is set to
Oldest(earliest)on the client, messages are reconsumed from the earliest offset.The client may remain in the Rebalance state.
Solutions
We recommend that you replace your Sarama Go client with a Confluent Go client at the earliest opportunity.
For information about the demo of Confluent Go clients, see kafka-confluent-go-demo.
If you cannot replace the client, perform the following operations:
In the production environment, set the consumer offset reset policy to
Newest(latest). In the debugging environment or other environments in which messages can be repeatedly consumed, set the consumer offset reset policy toOldest(earliest).If a large number of messages are accumulated due to consumer offset reset, you can reset the consumer offset to the offset at a specific point in time in the ApsaraMQ for Kafka console. This way, you do not need to modify the client code or change the consumer group to reset the consumer offset. For more information, see Reset consumer offsets.