public SessionSubscriptionReceiver(ServiceBusSettings settings, string topic, string subscription, bool requiresSequentialProcessing, ISessionSubscriptionReceiverInstrumentation instrumentation) : this(settings, topic, subscription, requiresSequentialProcessing, instrumentation, new ExponentialBackoff(10, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(1))) { }
public SessionSubscriptionReceiver(ServiceBusSettings settings, string topic, string subscription, bool requiresSequentialProcessing, ISessionSubscriptionReceiverInstrumentation instrumentation) : this( settings, topic, subscription, requiresSequentialProcessing, instrumentation, new ExponentialBackoff(10, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(1))) { }
protected SessionSubscriptionReceiver(ServiceBusSettings settings, string topic, string subscription, bool requiresSequentialProcessing, ISessionSubscriptionReceiverInstrumentation instrumentation, int maxRetryNumber, RetryStrategy backgroundRetryStrategy) { this.settings = settings; this.topic = topic; this.subscription = subscription; this.requiresSequentialProcessing = requiresSequentialProcessing; this.instrumentation = instrumentation; var messagingFactory = MessagingFactory.CreateFromConnectionString(this.settings.ConnectionString); this.client = messagingFactory.CreateSubscriptionClient(topic, subscription); if (this.requiresSequentialProcessing) { this.client.PrefetchCount = 10; } else { this.client.PrefetchCount = 15; } this.dynamicThrottling = new DynamicThrottling( maxDegreeOfParallelism: 500, minDegreeOfParallelism: 30, penaltyAmount: 3, workFailedPenaltyAmount: 5, workCompletedParallelismGain: 1, intervalForRestoringDegreeOfParallelism: 10000); this.retryStrategy = backgroundRetryStrategy; this.maxRetryNumber = maxRetryNumber; this.receiveRetryPolicy = new RetryPolicy <ServiceBusTransientErrorDetectionStrategy>(backgroundRetryStrategy); this.receiveRetryPolicy.Retrying += (s, e) => { this.dynamicThrottling.Penalize(); Trace.TraceWarning( "An error occurred in attempt number {1} to receive a message from subscription {2}: {0}", e.LastException.Message, e.CurrentRetryCount, this.subscription); }; }
/// <summary> /// Initializes a new instance of the <see cref="SessionSubscriptionReceiver"/> class, /// automatically creating the topic and subscription if they don't exist. /// </summary> protected SessionSubscriptionReceiver(ServiceBusSettings settings, string topic, string subscription, bool requiresSequentialProcessing, ISessionSubscriptionReceiverInstrumentation instrumentation, RetryStrategy backgroundRetryStrategy) { this.settings = settings; this.topic = topic; this.subscription = subscription; this.requiresSequentialProcessing = requiresSequentialProcessing; this.instrumentation = instrumentation; this.tokenProvider = TokenProvider.CreateSharedSecretTokenProvider(settings.TokenIssuer, settings.TokenAccessKey); this.serviceUri = ServiceBusEnvironment.CreateServiceUri(settings.ServiceUriScheme, settings.ServiceNamespace, settings.ServicePath); var messagingFactory = MessagingFactory.Create(this.serviceUri, tokenProvider); this.client = messagingFactory.CreateSubscriptionClient(topic, subscription); if (this.requiresSequentialProcessing) { this.client.PrefetchCount = 10; } else { this.client.PrefetchCount = 15; } this.dynamicThrottling = new DynamicThrottling( maxDegreeOfParallelism: 160, minDegreeOfParallelism: 30, penaltyAmount: 3, workFailedPenaltyAmount: 5, workCompletedParallelismGain: 1, intervalForRestoringDegreeOfParallelism: 10000); this.receiveRetryPolicy = new RetryPolicy <ServiceBusTransientErrorDetectionStrategy>(backgroundRetryStrategy); this.receiveRetryPolicy.Retrying += (s, e) => { this.dynamicThrottling.Penalize(); Trace.TraceWarning( "An error occurred in attempt number {1} to receive a message from subscription {2}: {0}", e.LastException.Message, e.CurrentRetryCount, this.subscription); }; }
protected SessionSubscriptionReceiver(ServiceBusSettings settings, string topic, string subscription, bool requiresSequentialProcessing, ISessionSubscriptionReceiverInstrumentation instrumentation, int maxRetryNumber, RetryStrategy backgroundRetryStrategy) { this.settings = settings; this.topic = topic; this.subscription = subscription; this.requiresSequentialProcessing = requiresSequentialProcessing; this.instrumentation = instrumentation; var messagingFactory = MessagingFactory.CreateFromConnectionString(this.settings.ConnectionString); this.client = messagingFactory.CreateSubscriptionClient(topic, subscription); if (this.requiresSequentialProcessing) { this.client.PrefetchCount = 10; } else { this.client.PrefetchCount = 15; } this.dynamicThrottling = new DynamicThrottling( maxDegreeOfParallelism: 500, minDegreeOfParallelism: 30, penaltyAmount: 3, workFailedPenaltyAmount: 5, workCompletedParallelismGain: 1, intervalForRestoringDegreeOfParallelism: 10000); this.retryStrategy = backgroundRetryStrategy; this.maxRetryNumber = maxRetryNumber; this.receiveRetryPolicy = new RetryPolicy<ServiceBusTransientErrorDetectionStrategy>(backgroundRetryStrategy); this.receiveRetryPolicy.Retrying += (s, e) => { this.dynamicThrottling.Penalize(); Trace.TraceWarning( "An error occurred in attempt number {1} to receive a message from subscription {2}: {0}", e.LastException.Message, e.CurrentRetryCount, this.subscription); }; }
/// <summary> /// Initializes a new instance of the <see cref="SessionSubscriptionReceiver"/> class, /// automatically creating the topic and subscription if they don't exist. /// </summary> protected SessionSubscriptionReceiver(ServiceBusSettings settings, string topic, string subscription, bool requiresSequentialProcessing, ISessionSubscriptionReceiverInstrumentation instrumentation, RetryStrategy backgroundRetryStrategy) { this.settings = settings; this.topic = topic; this.subscription = subscription; this.requiresSequentialProcessing = requiresSequentialProcessing; this.instrumentation = instrumentation; this.tokenProvider = TokenProvider.CreateSharedSecretTokenProvider(settings.TokenIssuer, settings.TokenAccessKey); this.serviceUri = ServiceBusEnvironment.CreateServiceUri(settings.ServiceUriScheme, settings.ServiceNamespace, settings.ServicePath); var messagingFactory = MessagingFactory.Create(this.serviceUri, tokenProvider); this.client = messagingFactory.CreateSubscriptionClient(topic, subscription); if (this.requiresSequentialProcessing) { this.client.PrefetchCount = 10; } else { this.client.PrefetchCount = 15; } this.dynamicThrottling = new DynamicThrottling( maxDegreeOfParallelism: 160, minDegreeOfParallelism: 30, penaltyAmount: 3, workFailedPenaltyAmount: 5, workCompletedParallelismGain: 1, intervalForRestoringDegreeOfParallelism: 10000); this.receiveRetryPolicy = new RetryPolicy<ServiceBusTransientErrorDetectionStrategy>(backgroundRetryStrategy); this.receiveRetryPolicy.Retrying += (s, e) => { this.dynamicThrottling.Penalize(); Trace.TraceWarning( "An error occurred in attempt number {1} to receive a message from subscription {2}: {0}", e.LastException.Message, e.CurrentRetryCount, this.subscription); }; }