简体   繁体   English

如何增加天蓝色的时代大小

[英]how to increase size of the epoch at azure

What I am supposed to do to increase the size of the epoch ? 我应该怎么做才能增加纪元的大小? I get following error: 我收到以下错误:

com.microsoft.azure.eventhubs.ReceiverDisconnectedException: New receiver with higher epoch of '1544084492' is created hence current receiver with epoch '1544084474' is getting disconnected. com.microsoft.azure.eventhubs.ReceiverDisconnectedException:创建了新的接收器,其新纪元为'1544084492',因此当前接收器的纪元为'1544084474'已断开连接。 If you are recreating the receiver, make sure a higher epoch is used. 如果要重新创建接收器,请确保使用更高的纪元。

Is this a problem which comes from azure or I have to change something at my test application ? 这是由于天蓝色引起的问题,还是我必须在测试应用程序中进行某些更改?

Hope I was clear. 希望我很清楚。

Thank you for your helps. 谢谢您的帮助。

There are two reasons for this, either: 这有两个原因,或者:

You have two applications using the same consumer group to access the event hub. 您有两个使用相同使用者组的应用程序来访问事件中心。 Either rework your architecture to have one client application, or use a new consumer group for each client. 要么重新设计体系结构以拥有一个客户端应用程序,要么为每个客户端使用一个新的使用者组。 If you are trying to parallelise processing, pull a batch of events from the hub and then process them in parallel, don't have multiple readers on the same consumer group. 如果要并行化处理,请从集线器中提取一批事件,然后并行处理它们,同一使用者组上不要有多个读取器。

OR 要么

Event hubs is internally moving partitions around from one host to another behind the scenes. 事件中心在内部将分区从一台主机移动到幕后的另一台主机。 In this case use a simply retry in your code and this should work. 在这种情况下,请在您的代码中使用简单的重试,这样就可以了。 For this I use Polly . 为此,我使用Polly Actually, in practice, it is usually a good idea to wrap code calling "the cloud" in a retry. 实际上,实际上,在重试中包装称为“云”的代码通常是一个好主意。

A sample retry policy could be as follows (you need to include the Polly Nuget package ): 重试策略示例如下(您需要包含Polly Nuget包 ):

namespace RetryPolicies
{
    using Microsoft.Extensions.Logging;
    using Polly;
    using Polly.Retry;
    using System;

    public class ExponentialRetryManager
    {
        private static readonly int MAX_RETRIES = 6;
        private RetryPolicy _retryPolicy;

        /// <summary>
        /// An exponential retry manager that will wait as follows between retries:
        ///                     
        //  2 ^ 1 = 2 seconds first, then 
        //  2 ^ 2 = 4 seconds then
        //  2 ^ 3 = 8 seconds then
        //  2 ^ 4 = 16 seconds then
        //  2 ^ 5 = 32 seconds
        //  2 ^ 6 = 64 seconds
        /// </summary>
        public ExponentialRetryManager(ILogger logger, String exceptionName = null)
        {
            _retryPolicy = Policy
                .Handle<Exception>()
                .WaitAndRetry(MAX_RETRIES, retryAttempt =>
                TimeSpan.FromSeconds(Math.Pow(1, retryAttempt)),
                (ex, timeSpan, retryAttempt, context) =>
                {
                    logger.LogWarning($"Warning! [RetryAttempt={retryAttempt.ToString()}],[Ex={ex.ToString()}]");
                });
        }

        /// <summary>
        /// Executes the passed in action using the retry policy in order to
        /// keep attempting to process until the MAX_RETRIES are reached. 
        /// </summary>
        /// <param name="action"></param>
        public void Retry(Action action)
        {
            _retryPolicy.Execute(() => action());
        }
    }
}

and you call it as follows: 并且您将其称为如下:

var retryManager = new ExponentialRetryManager(log);
retryManager.Retry(() => YourMethodToProcessEventHub());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM