I agree, this has always really annoyed me. This will definitely require a KIP since it's a public feature, but it should (hopefully!) be a fairly quick and non-controversial one. You can read up on the process and get started here <https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Improvement+Proposals>
I'd also recommend filing a JIRA ticket and replying to this thread with the link. Jira is a better place to host the debate, if there is any, and discuss possible solutions or ask questions. Cheers, Sophie On Fri, Oct 22, 2021 at 11:23 AM Steven Schlansker < stevenschlans...@gmail.com> wrote: > Hello Kafka friends, > > We are writing test code that sometimes will talk to a MockProducer > and sometimes to a normal KafkaProducer. Therefore the test harness > will sometimes read the MockProducer-produced records (ProducerRecord) > directly, and sometimes will read actual ConsumerRecords through a > real Consumer from the in-process test broker. > > We would like to be able to assert over a record, whether producer or > consumer, but the classes do not have any common interface. Most of > the properties are shared: topic, partition, headers, key, value, and > timestamp. > > A straightforward improvement would be to have both ConsumerRecord and > ProducerRecord implement a common interface, KafkaRecord<K,V>, with > accessors for these properties. > > I'm happy to contribute the code which should be straightforward but > wanted to validate this idea and make sure it is a contribution that > would be accepted before spending the time to do this. In particular > it might require a KIP even though it's a trivial feature since the > public API is affected. > > Does this sound like a good idea to implement? What would the next steps > be? > > Thanks! > Steven >