如何在 azure 中增加 epoch 的大小
how to increase size of the epoch at azure
我应该怎么做才能增加纪元的大小?我收到以下错误:
com.microsoft.azure.eventhubs.ReceiverDisconnectedException: New
receiver with higher epoch of '1544084492' is created hence current
receiver with epoch '1544084474' is getting disconnected. If you are
recreating the receiver, make sure a higher epoch is used.
这是天蓝色的问题还是我必须在我的测试应用程序中更改某些内容?
希望我说清楚了。
感谢您的帮助。
这有两个原因:
您有两个应用程序使用同一个使用者组来访问事件中心。要么重新设计您的体系结构以拥有一个客户端应用程序,要么为每个客户端使用一个新的消费者组。如果您尝试并行处理,从集线器中提取一批事件,然后并行处理它们,请不要在同一个消费者组中有多个读者。
或
事件中心正在内部将分区从一台主机移动到另一台主机。在这种情况下,只需在您的代码中重试即可,这应该会起作用。为此,我使用 Polly。实际上,在实践中,将调用 "the cloud" 的代码包装在重试中通常是个好主意。
示例重试策略如下(您需要包含 Polly Nuget package):
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());
}
}
}
你这样称呼它:
var retryManager = new ExponentialRetryManager(log);
retryManager.Retry(() => YourMethodToProcessEventHub());
我应该怎么做才能增加纪元的大小?我收到以下错误:
com.microsoft.azure.eventhubs.ReceiverDisconnectedException: New receiver with higher epoch of '1544084492' is created hence current receiver with epoch '1544084474' is getting disconnected. If you are recreating the receiver, make sure a higher epoch is used.
这是天蓝色的问题还是我必须在我的测试应用程序中更改某些内容?
希望我说清楚了。
感谢您的帮助。
这有两个原因:
您有两个应用程序使用同一个使用者组来访问事件中心。要么重新设计您的体系结构以拥有一个客户端应用程序,要么为每个客户端使用一个新的消费者组。如果您尝试并行处理,从集线器中提取一批事件,然后并行处理它们,请不要在同一个消费者组中有多个读者。
或
事件中心正在内部将分区从一台主机移动到另一台主机。在这种情况下,只需在您的代码中重试即可,这应该会起作用。为此,我使用 Polly。实际上,在实践中,将调用 "the cloud" 的代码包装在重试中通常是个好主意。
示例重试策略如下(您需要包含 Polly Nuget package):
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());
}
}
}
你这样称呼它:
var retryManager = new ExponentialRetryManager(log);
retryManager.Retry(() => YourMethodToProcessEventHub());