Q:

How do I view the full TCP packet that Apache Kafka produces?

I am using Apache Kafka. I use KafkaProducer to produce data and KafkaConsumer to consume data. My config data is:
Properties props = new Properties();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
props.put(ProducerConfig.CLIENT_ID_CONFIG, "DemoProducer");
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.IntegerSerializer");
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");

The consumer config is the same. How do I view the whole TCP packet details which are being sent and received by the producers and consumers?

A:

You can use tshark with a Kafka dissector already available.
sudo apt-get update
sudo apt-get install tshark
sudo tshark -V -i lo -o 'kafka.tcp.port:9092' -d tcp.port=9092,kafka -f 'dst port 9092'

More details here Using the kafka dissector in wireshark/tshark 1.12

