コード例 #1
0
            public async Task StartAsync()
            {
                this.shutdownSource = new CancellationTokenSource();
                this.shutdownTask   = this.WaitForShutdownAsync();

                try
                {
                    this.host.logger.LogDebug("PartitionInstance {eventHubName}/{eventHubPartition}({incarnation}) is starting partition", this.host.eventHubPath, this.partitionId, this.Incarnation);

                    // start this partition (which may include waiting for the lease to become available)
                    this.partition = this.host.host.AddPartition(this.partitionId, this.host.sender);

                    var errorHandler = this.host.host.CreateErrorHandler(this.partitionId);

                    var nextPacketToReceive = await this.partition.CreateOrRestoreAsync(errorHandler, this.host.parameters.StartPositions[Convert.ToInt32(this.partitionId)]).ConfigureAwait(false);

                    this.host.logger.LogInformation("PartitionInstance {eventHubName}/{eventHubPartition}({incarnation}) started partition, next expected packet is #{nextSeqno}", this.host.eventHubPath, this.partitionId, this.Incarnation, nextPacketToReceive);

                    this.partitionEventLoop = Task.Run(() => this.PartitionEventLoop(nextPacketToReceive));
                }
                catch (Exception e) when(!Utils.IsFatal(e))
                {
                    this.host.logger.LogError("PartitionInstance {eventHubName}/{eventHubPartition}({incarnation}) failed to start partition: {exception}", this.host.eventHubPath, this.partitionId, this.Incarnation, e);
                    throw;
                }
            }
コード例 #2
0
 public MemoryPartitionQueue(TransportAbstraction.IPartition partition, CancellationToken cancellationToken, ILogger logger)
     : base(cancellationToken, $"Part{partition.PartitionId:D2}", logger)
 {
     this.partition = partition;
 }