我正在使用Kafka 0.10.2 KafkaProducer
来生成主题中的数据。
以下是我的代码。
ProducerRecord record = new ProducerRecord(topic, (Integer)null, Long.valueOf(System.currentTimeMillis()), partitionKey.getBytes(), message.getBytes());
Future<RecordMetadata> future = this.producer.send(record, new Callback() {
public void onCompletion(RecordMetadata recordMetadata, Exception e) {
if(e != null) {
LOGGER.error("Error producing to topic " + partitionKey, e.getCause());
} else {
LOGGER.info(" Successfully produced topic " + recordMetadata.topic() + " on partition " + recordMetadata.partition() + "at " + recordMetadata.timestamp());
}
}
});
此消息通过不同群集中的mirrormaker进行复制。我编写了一个Mirrormaker处理程序来发送捕获延迟的消息。 当我检查mirrormaker消费者的时间戳时。我无法看到时间戳。下面是mirrormaker处理程序的代码。
@Override
public List<ProducerRecord<byte[], byte[]>> handle(BaseConsumerRecord record) {
LOGGER.debug("Timestamp from dal producer "+record.timestamp());
return Collections.singletonList(new ProducerRecord<byte[], byte[]>(topicToSend,partitionToSend,timeStampAtMM, record.key(), record.value()));
}