问题
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?
回答1:
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
回答2:
After you installed Wireshark, you must go to Edit->Prefrences
or press Ctrl + Shift + P
. In the new window open protocols
tree and find Kafka
in the list. After selecting Kafka
you must set the Kafka broker port numbers(It's by default 9092). And Also check Show length for string and bytes fields in the protocol tree
checkbox as shown in blew image:
and click ok to dismiss the window. And then you can view all Kafka APIs calls:
来源:https://stackoverflow.com/questions/38352631/how-do-i-view-the-full-tcp-packet-that-apache-kafka-produces