Azure事件处理器主机Java库-ReceiverRuntimeInformation在分区上没有实际统计信息 [英] Azure Event Processor Host java library - ReceiverRuntimeInformation doesn't have actual stats on a partition
问题描述
我试图通过利用PartitionContext在接收到事件时提供的ReceiverRuntimeInformation对象来获取最后排队的序列号,以在消费者端跟踪消费者和生产者之间的滞后.但是,ReceiverRuntimeInformation对象没有与事件中心的特定分区相关的更新值,它返回0.示例代码和日志输出如下:
I am trying to get the last enqueued sequence number to track the lag between consumer and producer at the consumer end by leveraging ReceiverRuntimeInformation object provided by PartitionContext when a event is received. However, ReceiverRuntimeInformation object doesn't have the updated values related to that particular partition of an Event Hub, it returns 0. Sample code and log output below:
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
推荐答案
这是一项可选功能.创建EventProcessorHost
实例时,将EventProcessorOptions
传递给:
This is an opt-in feature. While creating the EventProcessorHost
instance, pass in EventProcessorOptions
with:
eventProcessorOptions.setReceiverRuntimeMetricEnabled(true);
我们将此功能设计为Opt-in
功能-因为它会为接收到的所有EventHub消息添加额外的字节(sdk使用客户端通过线路接收到的所有EventData
-来传输此额外信息).
We designed this as an Opt-in
feature - as it adds additional bytes to all EventHub messages received (sdk uses all EventData
received on the wire by the client - to transmit this extra information).
注意:RecieverRuntimeInformation
中存在的数据为dynamic
,因此可以为stale
!例如-ReceiverRuntimeInformation.LastEnqueuedSequenceNumber
可能会在服务实际回复时更改!因为该分区上可能会有新的事件.为了使数据相关-我们添加了一个名为RetrievalTime
的属性-实际上是从服务中检索ReceiverRuntimeInformation
的时间.这可以帮助理解-ReceiverRuntimeInformation
的值有多陈旧.
Note: Data present in RecieverRuntimeInformation
is dynamic
and hence can be stale
! For instance - ReceiverRuntimeInformation.LastEnqueuedSequenceNumber
could change by the time service actually responded back! as there could be new Events on that Partition. To make the data relevant - we added a property named - RetrievalTime
- which is actually when the ReceiverRuntimeInformation
was retrieved from the service. This can help understand - how stale the value of ReceiverRuntimeInformation
is.
这篇关于Azure事件处理器主机Java库-ReceiverRuntimeInformation在分区上没有实际统计信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!