Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get events count from Microsoft Azure EventHub?

I want to get events count from Microsoft Azure EventHub. I can use EventHubReceiver.Receive(maxcount) but it is slow on big number of big events.

There is NamespaceManager.GetEventHubPartition(..).EndSequenceNumber property that seems to be doing the trick but I am not sure if it is correct approach.

like image 516
Val Avatar asked Sep 13 '14 00:09

Val


1 Answers

EventHub doesn't have a notion of Message count, as EventHub is a high-Throughput, low-latency durable stream of events on cloud - getting the CORRECT current count at a given point of time, could be wrong the very next milli-second!! and hence, it wasn't provided :)

Hmm, we should have named EventHubs something like a StreamHub - which would make this obvious!!

If what you are looking for is - how much is the Receiver lagging behind - then EventHubClient.GetPartitionRuntimeInformation().LastEnqueuedSequenceNumber is your Best bet.

As long as no messages are sent to the partition this value remains constant :)

On the Receiver side - when a message is received - receivedEventData.SequenceNumber will indicate the Current sequence number you are processing and the diff. between EventHubClient.GetPartitionRuntimeInformation().LastEnqueuedSequenceNumber and EventData.SequenceNumber can indicate how much the Receiver of a Partition is lagging behind - based on which, the receiver process can Scale up or down the no. of Workers (work distribution logic).

more on Event Hubs...

like image 157
Sreeram Garlapati Avatar answered Sep 30 '22 19:09

Sreeram Garlapati