Hello!

Recently, I had an opportunity to work with legacy code that was using an
old version of the Kafka native producer transactional API. Our goal was to
upgrade the code to the newest version and benefit from the upgraded
transactional API protocol. Initially, we found code that was highlighted
as deprecated (
https://kafka.apache.org/25/javadoc/org/apache/kafka/clients/producer/Producer.html#sendOffsetsToTransaction-java.util.Map-java.lang.String-
):

> kafkaProducer.sendOffsetsToTransaction(Map.of(new
> TopicPartition(record.topic(), record.partition()), new
> OffsetAndMetadata(record.offset())), groupId);
>

Our first approach was to use the non-deprecated API:

kafkaProducer.sendOffsetsToTransaction(Map.of(new
> TopicPartition(record.topic(), record.partition()), new
> OffsetAndMetadata(record.offset())), new ConsumerGroupMetadata(groupId));


A few days later, after an extensive testing session, we finally read the
new sendOffsetsToTransaction method javadoc and discovered that we needed
to retrieve metadata from the Kafka Consumer.

>From our perspective, this upgrade process was more complicated than
expected and requires broad knowledge of the transactional protocol
upgrade. Are there any contradictions in making the public
ConsumerGroupMetadata(String
groupId) constructor deprecated too? It would have given us a clear hint
that we were still doing something wrong from the start.

-- 
Pozdrawiam
Paweł Szymczyk

Reply via email to