KAFKA:找到发布消息的分区?

时间:2016-02-24 10:00:40

标签: apache-kafka kafka-producer-api

我发布了一条消息 KeyedMessage data = new KeyedMessage(“topic”,partition_key,msg);

如何重新检查邮件是否转到哪个分区?

1 个答案:

答案 0 :(得分:1)

当您使用send()致电KeyedMessage时,会返回Future<RecordMetadata>。使用RecordMetadata.partition()获取分区。 offset()返回偏移量。见这里:

http://kafka.apache.org/082/javadoc/org/apache/kafka/clients/producer/RecordMetadata.html