private async Task OnFailure(GuidId subscriptionId, string streamProviderName, StreamId streamId, StreamSequenceToken sequenceToken) { if (subscriptionId == null) { throw new ArgumentNullException("subscriptionId"); } if (string.IsNullOrWhiteSpace(streamProviderName)) { throw new ArgumentNullException("streamProviderName"); } var failureEntity = createEntity(); failureEntity.SubscriptionId = subscriptionId.Guid; failureEntity.StreamProviderName = streamProviderName; failureEntity.StreamGuid = streamId.GetKeyAsString(); failureEntity.StreamNamespace = streamId.GetNamespace(); failureEntity.SetSequenceToken(this.serializationManager, sequenceToken); failureEntity.SetPartitionKey(this.clusterId); failureEntity.SetRowkey(); await dataManager.CreateTableEntryAsync(failureEntity); }
/// <inheritdoc /> public bool TryReadEvents(int maxCount, out IEnumerable <EventData> events) { if (!this.ShouldProduce) { events = null; return(false); } int count = maxCount; List <EventData> eventDataList = new List <EventData>(); while (count-- > 0) { this.SequenceNumberCounter.Increment(); var eventData = EventHubBatchContainer.ToEventData <int>( this.serializationManager, this.StreamId, this.GenerateEvent(this.SequenceNumberCounter.Value), RequestContextExtensions.Export(this.serializationManager)); var wrapper = new WrappedEventData( eventData.Body, eventData.Properties, eventData.SystemProperties, partitionKey: StreamId.GetKeyAsString(), offset: DateTime.UtcNow.Ticks, sequenceNumber: this.SequenceNumberCounter.Value); eventDataList.Add(wrapper); this.logger.Info($"Generate data of SequemceNumber {SequenceNumberCounter.Value} for stream {this.StreamId}"); } events = eventDataList; return(eventDataList.Count > 0); }
/// <summary> /// Get the Event Hub partition key to use for a stream. /// </summary> /// <param name="streamId">The stream Guid.</param> /// <returns>The partition key to use for the stream.</returns> public virtual string GetPartitionKey(StreamId streamId) => streamId.GetKeyAsString();