Command to view message timestamps: kafka-console-consumer –bootstrap-server localhost:9092 –property print.timestamp=true –topic test –from-beginning CreateTime (-1) for all sarama producers in kafka. The timestamp pushed by the command line to Kafka is fine.
Reason: Sarama supports kafka version 0.8.2 by default, while timestamp is supported from version 0.10. Therefore, you need to specify the following version of Kafka when initializing the producer configuration.
kfkConf := sarama.NewConfig() kfkConf.Version = sarama.V0_10_0_0