我试图通过在接收到事件时利用 PartitionContext 提供的 ReceiverRuntimeInformation 对象来获取最后一个排队的序列号来跟踪消费者端的消费者和生产者之间的滞后。但是,ReceiverRuntimeInformation 对象没有与事件中心的特定分区相关的更新值,它返回 0。示例代码和日志输出如下:
public class EventProcessor extends IEventProcessorImpl{
@Override
public void onEvents(PartitionContext context, Iterable<EventData> messages) throws Exception {
ReceiverRuntimeInformation rte = context.getRuntimeInformation();
logger.info(rte.getLastEnqueuedOffset() + " * " + rte.getLastEnqueuedSequenceNumber() + " * " + rte.getPartitionId() + " * " + rte.getRetrievalTime());
}
}
输出:
null * 0 * 3 * null