Asp.net core 公共交通和Azure服务巴士计划重试
我们的公共交通/Azure服务总线设置运行得很好,但还有一个功能我们很想使用,但似乎不起作用-计划重新交付 以下是启动中的代码:Asp.net core 公共交通和Azure服务巴士计划重试,asp.net-core,azureservicebus,masstransit,Asp.net Core,Azureservicebus,Masstransit,我们的公共交通/Azure服务总线设置运行得很好,但还有一个功能我们很想使用,但似乎不起作用-计划重新交付 以下是启动中的代码: busFactoryConfig.UseServiceBusMessageScheduler(); busFactoryConfig.SubscriptionEndpoint(Constants.SubscriptionName, Constants.TopicName, configurator => {
busFactoryConfig.UseServiceBusMessageScheduler();
busFactoryConfig.SubscriptionEndpoint(Constants.SubscriptionName, Constants.TopicName, configurator =>
{
configurator.UseScheduledRedelivery(r => r.Intervals(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(30)));
configurator.UseMessageRetry(r =>
{
r.Immediate(2);
r.Ignore<InvalidCastException>(); //we don't want to retry here, the message content is invalid
});
这给我们带来了一个不同的错误:
InvalidAudience: The authorization header contains a token with a wrong audience.
快速阅读会发现这与Azure如何使用密钥有关,而且可能已经过时。然而,这就是我用来成功连接到总线的同一个URI——我所做的只是删除Endpoint=以便在构造新URI()时它是一个有效的URI
Azure服务总线的计划重新交付是否与MT一起工作?配置中是否缺少某些内容
任何帮助都将不胜感激。您不能使用订阅端点进行重新交付。如果要使用“重新传递”,我建议使用常规ReceiveEndpoint(消息将从主题转发到队列,队列由MassTransit使用消费者消息类型进行配置)
SubscriptionEndpoints特定于ASB,通常仅在您有要直接订阅的现有主题时使用。正如Chris在上面回答的那样-SubscriptionEndpoints不受支持,您必须改用ReceiveEndpoint。这对我很有用:
busFactoryConfig.UseServiceBusMessageScheduler();
busFactoryConfig.ReceiveEndpoint(Constants.SubscriptionName, configurator =>
{
configurator.UseScheduledRedelivery(r => r.Intervals(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(3)));
configurator.UseMessageRetry(r =>
{
r.Immediate(2);
r.Ignore<InvalidCastException>(); //we don't want to retry here, the message content is invalid
});
configurator.ConfigureConsumer<MyConsumer>(context);
}
busFactoryConfig.UseServiceBusMessageScheduler();
busFactoryConfig.ReceiveEndpoint(Constants.SubscriptionName,configurator=>
{
configurator.useScheduledDelivery(r=>r.interval(TimeSpan.FromMinutes(1)、TimeSpan.FromMinutes(2)、TimeSpan.FromMinutes(3));
configurator.UseMessageRetry(r=>
{
r、 立即(2);
r、 Ignore();//我们不想在此处重试,消息内容无效
});
configurator.ConfigureConsumer(上下文);
}
InvalidAudience: The authorization header contains a token with a wrong audience.
busFactoryConfig.UseServiceBusMessageScheduler();
busFactoryConfig.ReceiveEndpoint(Constants.SubscriptionName, configurator =>
{
configurator.UseScheduledRedelivery(r => r.Intervals(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(3)));
configurator.UseMessageRetry(r =>
{
r.Immediate(2);
r.Ignore<InvalidCastException>(); //we don't want to retry here, the message content is invalid
});
configurator.ConfigureConsumer<MyConsumer>(context);
}