コード例 #1
0
 public SubscriptionReceiver(ServiceBusSettings settings, string topic, string subscription, bool processInParallel, ISubscriptionReceiverInstrumentation instrumentation)
     : this(
         settings,
         topic,
         subscription,
         processInParallel,
         instrumentation,
         10,
         new ExponentialBackoff(10, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(1)))
 {
 }
コード例 #2
0
 public SessionSubscriptionReceiver(ServiceBusSettings settings, string topic, string subscription, bool requiresSequentialProcessing, ISessionSubscriptionReceiverInstrumentation instrumentation)
     : this(
         settings,
         topic,
         subscription,
         requiresSequentialProcessing,
         instrumentation,
         10,
         new ExponentialBackoff(10, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(1)))
 {
 }
コード例 #3
0
        protected SubscriptionReceiver(ServiceBusSettings settings, string topic, string subscription, bool processInParallel, ISubscriptionReceiverInstrumentation instrumentation, int maxNumberRetry, RetryStrategy backgroundRetryStrategy)
        {
            this.settings          = settings;
            this.topic             = topic;
            this.subscription      = subscription;
            this.processInParallel = processInParallel;
            this.instrumentation   = instrumentation;

            var messagingFactory = MessagingFactory.CreateFromConnectionString(this.settings.ConnectionString);

            this.client = messagingFactory.CreateSubscriptionClient(topic, subscription);
            if (this.processInParallel)
            {
                this.client.PrefetchCount = 500;
            }
            else
            {
                this.client.PrefetchCount = 100;
            }

            this.dynamicThrottling =
                new DynamicThrottling(
                    maxDegreeOfParallelism: 10000,
                    minDegreeOfParallelism: 50,
                    penaltyAmount: 3,
                    workFailedPenaltyAmount: 5,
                    workCompletedParallelismGain: 1,
                    intervalForRestoringDegreeOfParallelism: 8000);

            this.retryStrategy  = backgroundRetryStrategy;
            this.maxNumberRetry = maxNumberRetry;

            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);
            };
        }
コード例 #4
0
ファイル: TopicSender.cs プロジェクト: hoangvv1409/codebase
        /// <summary>
        /// Initializes a new instance of the <see cref="TopicSender"/> class,
        /// automatically creating the given topic if it does not exist.
        /// </summary>
        protected TopicSender(ServiceBusSettings settings, string topic, int maxNumberRetry, RetryStrategy retryStrategy)
        {
            this.settings = settings;
            this.topic    = topic;

            this.retryStrategy  = retryStrategy;
            this.maxNumberRetry = maxNumberRetry;

            this.messagingFactory = MessagingFactory.CreateFromConnectionString(settings.ConnectionString);
            this.topicClient      = messagingFactory.CreateTopicClient(this.topic);

            this.retryPolicy           = new RetryPolicy <ServiceBusTransientErrorDetectionStrategy>(this.retryStrategy);
            this.retryPolicy.Retrying += (s, e) =>
            {
                var handler = this.Retrying;
                if (handler != null)
                {
                    handler(this, EventArgs.Empty);
                }

                Trace.TraceWarning("An error occurred in attempt number {1} to send a message: {0}", e.LastException.Message, e.CurrentRetryCount);
            };
        }
コード例 #5
0
 public ServiceBusConfig(ServiceBusSettings settings)
 {
     this.settings = settings;
 }
コード例 #6
0
ファイル: TopicSender.cs プロジェクト: hoangvv1409/codebase
 /// <summary>
 /// Initializes a new instance of the <see cref="TopicSender"/> class,
 /// automatically creating the given topic if it does not exist.
 /// </summary>
 public TopicSender(ServiceBusSettings settings, string topic)
     : this(settings, topic, 10, new ExponentialBackoff(10, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(1)))
 {
 }