2

我试图通过在接收到事件时利用 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
4

1 回答 1

3

这是一个可选功能。创建EventProcessorHost实例时,传入EventProcessorOptions

eventProcessorOptions.setReceiverRuntimeMetricEnabled(true);

我们将此设计为一项Opt-in功能 - 因为它为所有接收到EventData的 EventHub 消息添加了额外的字节(sdk 使用客户端在线路上接收到的所有消息 - 来传输这些额外信息)。

注意:存在的数据RecieverRuntimeInformationdynamic,因此可以是stale!例如 -ReceiverRuntimeInformation.LastEnqueuedSequenceNumber可能会在服务实际响应时发生变化!因为该分区上可能有新事件。为了使数据相关 - 我们添加了一个名为 -RetrievalTime实际上ReceiverRuntimeInformation是从服务中检索到的属性。这可以帮助理解 - 的值有多陈旧ReceiverRuntimeInformation

于 2018-08-15T19:31:58.460 回答