Пример #1
0
        private async Task <IEnumerable <EventData> > GetEventData()
        {
            EventHubRuntimeInformation runtimeInformation = _eventHubClient.GetRuntimeInformation();
            List <EventData>           dataRecieved       = new List <EventData>();

            foreach (string partitionId in runtimeInformation.PartitionIds)
            {
                string partitionOffset = await _stateHandler.GetOffset(partitionId);

                //EventHubReceiver eventReceiver = _eventHubClient.GetDefaultConsumerGroup().CreateReceiver(partitionId, partitionOffset);
                EventHubReceiver eventReceiver = _eventHubClient.GetConsumerGroup("mojo").CreateReceiver(partitionId, partitionOffset);

                EventData eventData = eventReceiver.Receive();

                await _stateHandler.SetOffset(eventData.Offset, partitionId);

                await eventReceiver.CloseAsync();

                dataRecieved.Add(eventData);
            }

            return(dataRecieved);
        }