Exemple #1
0
        private static async Task <EventHubReceiver> CreateReceiver(EventHubPartitionConfig partitionConfig, string offset, Logger logger)
        {
            bool                  offsetInclusive = true;
            EventHubClient        client          = EventHubClient.CreateFromConnectionString(partitionConfig.Hub.ConnectionString, partitionConfig.Hub.Path);
            EventHubConsumerGroup consumerGroup   = client.GetConsumerGroup(partitionConfig.Hub.ConsumerGroup);

            if (partitionConfig.Hub.PrefetchCount.HasValue)
            {
                consumerGroup.PrefetchCount = partitionConfig.Hub.PrefetchCount.Value;
            }
            // if we have a starting offset or if we're not configured to start reading from utc now, read from offset
            if (!partitionConfig.Hub.StartFromNow || offset != EventHubConsumerGroup.StartOfStream)
            {
                logger.Info("Starting to read from EventHub partition {0}-{1} at offset {2}", partitionConfig.Hub.Path, partitionConfig.Partition, offset);
            }
            else
            {
                // to start reading from most recent data, we get the latest offset from the partition.
                PartitionRuntimeInformation patitionInfo =
                    await client.GetPartitionRuntimeInformationAsync(partitionConfig.Partition);

                offset          = patitionInfo.LastEnqueuedOffset;
                offsetInclusive = false;
                logger.Info("Starting to read latest messages from EventHub partition {0}-{1} at offset {2}", partitionConfig.Hub.Path, partitionConfig.Partition, offset);
            }
            return(await consumerGroup.CreateReceiverAsync(partitionConfig.Partition, offset, offsetInclusive));
        }
 public EventHubAdapterReceiver(EventHubPartitionConfig partitionConfig,
                                Func <IStreamQueueCheckpointer <string>, IEventHubQueueCache> cacheFactory,
                                Func <string, Task <IStreamQueueCheckpointer <string> > > checkpointerFactory,
                                Logger log)
 {
     this.cacheFactory        = cacheFactory;
     this.checkpointerFactory = checkpointerFactory;
     config = partitionConfig;
 }
        private EventHubAdapterReceiver MakeReceiver(QueueId queueId)
        {
            var config = new EventHubPartitionConfig
            {
                Hub       = hubSettings,
                Partition = streamQueueMapper.QueueToPartition(queueId),
            };

            return(new EventHubAdapterReceiver(config, CacheFactory, CheckpointerFactory, logger));
        }
Exemple #4
0
        private EventHubAdapterReceiver MakeReceiver(QueueId queueId)
        {
            var config = new EventHubPartitionConfig
            {
                Hub       = hubSettings,
                Partition = streamQueueMapper.QueueToPartition(queueId),
            };

            return(new EventHubAdapterReceiver(config, bufferPool, logger));
        }
        private EventHubAdapterReceiver MakeReceiver(QueueId queueId)
        {
            var config = new EventHubPartitionConfig
            {
                Hub       = hubSettings,
                Partition = streamQueueMapper.QueueToPartition(queueId),
            };
            Logger recieverLogger = logger.GetSubLogger($".{config.Partition}");

            return(new EventHubAdapterReceiver(config, CacheFactory, CheckpointerFactory, recieverLogger));
        }
Exemple #6
0
        private EventHubAdapterReceiver MakeReceiver(QueueId queueId)
        {
            var config = new EventHubPartitionConfig
            {
                Hub = hubSettings,
                CheckpointSettings = checkpointSettings,
                StreamProviderName = adapterConfig.StreamProviderName,
                Partition          = streamQueueMapper.QueueToPartition(queueId),
            };

            return(new EventHubAdapterReceiver(config, bufferPool, logger));
        }
        private static Task <EventHubReceiver> CreateReceiver(EventHubPartitionConfig partitionConfig, string offset)
        {
            EventHubClient        client        = EventHubClient.CreateFromConnectionString(partitionConfig.Hub.ConnectionString, partitionConfig.Hub.Path);
            EventHubConsumerGroup consumerGroup = client.GetConsumerGroup(partitionConfig.Hub.ConsumerGroup);

            if (partitionConfig.Hub.PrefetchCount.HasValue)
            {
                consumerGroup.PrefetchCount = partitionConfig.Hub.PrefetchCount.Value;
            }
            // if we have a starting offset or if we're not configured to start reading from utc now, read from offset
            if (!partitionConfig.Hub.StartFromNow || offset != EventHubConsumerGroup.StartOfStream)
            {
                return(consumerGroup.CreateReceiverAsync(partitionConfig.Partition, offset, true));
            }
            return(consumerGroup.CreateReceiverAsync(partitionConfig.Partition, DateTime.UtcNow));
        }
Exemple #8
0
        public EventHubAdapterReceiver(EventHubPartitionConfig partitionConfig,
                                       Func <string, IStreamQueueCheckpointer <string>, Logger, IEventHubQueueCache> cacheFactory,
                                       Func <string, Task <IStreamQueueCheckpointer <string> > > checkpointerFactory,
                                       Logger logger)
        {
            this.cacheFactory        = cacheFactory;
            this.checkpointerFactory = checkpointerFactory;
            baseLogger  = logger;
            this.logger = logger.GetSubLogger("-receiver");
            config      = partitionConfig;

            hubReceiveTimeMetric                 = $"Orleans.ServiceBus.EventHub.ReceiveTime_{config.Hub.Path}";
            partitionReceiveTimeMetric           = $"Orleans.ServiceBus.EventHub.ReceiveTime_{config.Hub.Path}-{config.Partition}";
            hubReadFailure                       = $"Orleans.ServiceBus.EventHub.ReadFailure_{config.Hub.Path}";
            partitionReadFailure                 = $"Orleans.ServiceBus.EventHub.ReadFailure_{config.Hub.Path}-{config.Partition}";
            hubMessagesRecieved                  = $"Orleans.ServiceBus.EventHub.MessagesReceived_{config.Hub.Path}";
            partitionMessagesReceived            = $"Orleans.ServiceBus.EventHub.MessagesReceived_{config.Hub.Path}-{config.Partition}";
            hubAgeOfMessagesBeingProcessed       = $"Orleans.ServiceBus.EventHub.AgeOfMessagesBeingProcessed_{config.Hub.Path}";
            partitionAgeOfMessagesBeingProcessed = $"Orleans.ServiceBus.EventHub.AgeOfMessagesBeingProcessed_{config.Hub.Path}-{config.Partition}";
        }
Exemple #9
0
 public EventHubAdapterReceiver(EventHubPartitionConfig partitionConfig, IObjectPool <FixedSizeBuffer> bufferPool, Logger log)
 {
     config          = partitionConfig;
     this.bufferPool = bufferPool;
 }