Azure Event Processor Host java library - ReceiverRuntimeInformation doesn't have actual stats on a partition

情到浓时终转凉″ 提交于 2020-02-05 04:36:05

问题


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());
    }

}

Output:

null * 0 * 3 * null

回答1:


This is an opt-in feature. While creating the EventProcessorHost instance, pass in EventProcessorOptions with:

eventProcessorOptions.setReceiverRuntimeMetricEnabled(true);

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).

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.



来源:https://stackoverflow.com/questions/51823399/azure-event-processor-host-java-library-receiverruntimeinformation-doesnt-hav

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!