I have a use case where I need to publish whole file as a single message using Kafka Producer, so that when the consumer reads the message, consumer should be able to able to get whole file. I tried implementing this by converting the file to byte array and publish it to topic
byte[] fileData = Files.readAllBytes(Paths.get(path));
producer.send(new ProducerRecord<String, byte[]>("test", fileData));
When the same is consumed, each line is coming as a separate message