Search code examples
kafka-consumer-apispring-kafka

@KafkaListener produces ConsumerRecord instead of Avro Schema Object


My microservices are set up as follows. A -> B -> C The A produces to topic a.b and B produces to topic b.c The communication between A and B is perfect but I did not write it. The communication between B and C is broken and I did write it.

When the method annotated with @KafkaListener is called for B's reception of A's data, the data is neatly put in an object as our avro schema as defined (its sent using the avro serialization). This is not the case for C's consumer for B. The @KafkaListener function instead receives a ConsumerRecord. There is also a schema defined for B->C and we have it configured the same way as A->B but for some reason its acting differently.

I have copied A and B's Producer and Consumer configuration however I changed the schema involved.

Why is this, is there a configuration somewhere that I missed? Both are using the same version of org.springframework.kafka 2.2.7RELEASE.

There is a lot of code so lmk if you need more information.

Edit: it looks as though if the message is empty, the ConsumerRecord object is used. What reasons would cause the message to be be emptied. I can guarantee that the producer sends an object with information.


Solution

  • This occurs if the @KafkaListener cant deserialize the data being sent, often because you sent data with null values