我们可以使用nservicebus和MSMQ传输启用延迟重试。 当我这样做时,它会发出警告并将消息移动到错误队列。
“可恢复性策略已请求DelayedRetry但当前端点配置无法使用延迟传送功能。请将消息移至错误队列。”
但是根据nservicebus文档,它告诉我们如果支持延迟传送,则可以执行延迟重试。而且我对延迟交货有所了解。
“NServiceBus为没有延迟邮件传递的本机支持的传输提供延迟传递功能,即用于MSMQ和SQL Server传输。”
endpointConfiguration.SendFailedMessagesTo("error");
endpointConfiguration.AuditProcessedMessagesTo("audit");
endpointConfiguration.DisableFeature<TimeoutManager>();
var messageProcessingConcurrency = ConfigurationManager.AppSettings["NservicebusMessageProcessingConcurrency"];
endpointConfiguration.LimitMessageProcessingConcurrencyTo(int.Parse(messageProcessingConcurrency));
//configuring delayed retries
var recoverability = endpointConfiguration.Recoverability();
//recoverability.CustomPolicy(OrderRecoverability.CustomRetryPolicy);
recoverability.Delayed(
delayed =>
{
delayed.NumberOfRetries(2);
delayed.TimeIncrease(TimeSpan.FromMinutes(30));
});
//no imediate retries
recoverability.Immediate(
immediate =>
{
immediate.NumberOfRetries(0);
});
endpointConfiguration.UsePersistence<MsmqPersistence>();
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
var conventions = endpointConfiguration.Conventions();
conventions
.DefiningEventsAs(
t =>
t.Namespace != null
&& t.Namespace.StartsWith("Dodo.Fibre.Provisioning.Messages"));
根据要求,我已注释掉超时管理器禁用行,如下所示。 // endpointConfiguration.DisableFeature();
但我无法启动端点,因为我遇到了错误。
2017-08-01 08:45:28.074 FATAL NServiceBus.Hosting.Windows.WindowsHost Start fail
ure
System.Exception: The selected persistence doesn't have support for timeout stor
age. Select another persistence or disable the timeout manager feature using end
pointConfiguration.DisableFeature<TimeoutManager>()
at NServiceBus.Features.TimeoutManager.Setup(FeatureConfigurationContext cont
ext) in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\DelayedDelivery
\TimeoutManager\TimeoutManager.cs:line 34
at NServiceBus.Features.FeatureActivator.ActivateFeature(FeatureInfo featureI
nfo, List`1 featuresToActivate, IConfigureComponents container, PipelineSettings
pipelineSettings, RoutingComponent routing) in C:\BuildAgent\work\3206e2123f54f
ce4\src\NServiceBus.Core\Features\FeatureActivator.cs:line 194
at NServiceBus.Features.FeatureActivator.SetupFeatures(IConfigureComponents c
ontainer, PipelineSettings pipelineSettings, RoutingComponent routing) in C:\Bui
ldAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Features\FeatureActivator.cs:
line 57
at NServiceBus.InitializableEndpoint.<Initialize>d__1.MoveNext() in C:\BuildA
gent\work\3206e2123f54fce4\src\NServiceBus.Core\InitializableEndpoint.cs:line 60
答案 0 :(得分:0)
从您的配置代码中我可以看到您已禁用TimeoutManager,这就是延迟重试未按预期工作的原因,例如。
[hero]="selectedHero"
有什么理由吗?虽然像Azure ServiceBus / RabbitMQ这样的某些传输具有内置的延迟传递,但MSMQ没有这种传输,并且该工作由超时管理器管理。