当Kafka生产者调用send()方法时,它返回包含
的RecordMetadata的未来 public RecordMetadata(TopicPartition topicPartition,
long baseOffset,
long relativeOffset,
long timestamp,
java.lang.Long checksum,
int serializedKeySize,
int serializedValueSize)
这包含主题/分区中记录的时间戳,但是有一种方法可以找出代理发送的确认的时间戳。
我注意到确认收到延迟,并希望进一步调试以了解此延迟的原因。 Kafka代理中是否存在允许在服务器日志中打印确认信息的日志级别?
答案 0 :(得分:0)
我在Apache Kafka和Spring Kafka中都找到了TRACE日志级别。可能是你在找什么。
org.springframework.kafka.core.KafkaTemplate
protected ListenableFuture<SendResult<K, V>> doSend(final ProducerRecord<K, V> producerRecord) {
final Producer<K, V> producer = getTheProducer();
if (this.logger.isTraceEnabled()) {
this.logger.trace("Sending: " + producerRecord);
}
...
producer.send(producerRecord, new Callback() {
@Override
public void onCompletion(RecordMetadata metadata, Exception exception) {
...
if (KafkaTemplate.this.logger.isTraceEnabled()) {
KafkaTemplate.this.logger.trace("Sent ok: " + producerRecord + ", metadata: " + metadata);
}
...
}
}
...
}
org.apache.kafka.clients.producer.KafkaProducer
private Future<RecordMetadata> doSend(ProducerRecord<K, V> record, Callback
callback) {
...
log.trace("Sending record {} with callback {} to topic {} partition {}",
record, callback, record.topic(), partition);
...
}