即使如下所示指定了一个名为“ poison”的自定义队列,也会创建“错误”队列。
在下面登录:
[INF] Rebus.AzureServiceBus.AzureServiceBusTransport(线程1): 使用队列“ subscriber1”初始化zure Service Bus传输 [INF] Rebus.Threading.TaskParallelLibrary.TplAsyncTask(线程1): 从间隔00:00:10开始每个定期任务“ CleanupTrackedErrors” [INF] Rebus.Bus.RebusBus(线程1):将工作程序数量设置为5 [DBG] Rebus.Bus.RebusBus(线程1):添加工作程序“ Rebus 1 worker 1” [DBG] Rebus.Bus.RebusBus(线程1):添加工作程序“ Rebus 1 worker 2” [DBG] Rebus.Bus.RebusBus(线程1):添加工作程序“ Rebus 1 worker 3” [DBG] Rebus.Bus.RebusBus(线程1):添加工作程序“ Rebus 1 worker 4” [DBG] Rebus.Workers.ThreadPoolBased.ThreadPoolWorker(1个Rebus工作者 2):启动(基于线程池的)工作线程“ Rebus 1 worker 2” [DBG] Rebus.Workers.ThreadPoolBased.ThreadPoolWorker(Rebus 1工作器1): 启动(基于线程池的)工作程序“ Rebus 1工作程序1” [DBG] Rebus.Workers.ThreadPoolBased.ThreadPoolWorker(Rebus 1工作器3): 启动(基于线程池的)工作线程“ Rebus 1 worker 3” [DBG] Rebus.Bus.RebusBus(线程1):添加工作人员“ Rebus 1工作人员5” [DBG] Rebus.Workers.ThreadPoolBased.ThreadPoolWorker(Rebus 1工作器4): 启动(基于线程池的)工作线程“ Rebus 1 worker 4” [INF] Rebus.Bus.RebusBus(线程1):总线“ Rebus 1”已启动[DBG] Rebus.Workers.ThreadPoolBased.ThreadPoolWorker(Rebus 1工作器5): 启动(基于线程池的)工作线程“ Rebus 1 worker 5” [INF] Rebus.AzureServiceBus.AzureServiceBusTransport(线程#1): 使用队列“中毒” [INF]初始化Azure服务总线传输 Rebus.Threading.TaskParallelLibrary.TplAsyncTask(线程1):正在启动 定期任务“ CleanupTrackedErrors”,间隔为00:00:10 [INF] Rebus.AzureServiceBus.AzureServiceBusTransport(线程5):创建 ASB队列“错误” [INF] Rebus.Bus.RebusBus(线程1):设置号 到1个[DBG] Rebus.Bus.RebusBus的工作线程数(线程1):添加工作线程 “ Rebus 2工人1” [INF] Rebus.Bus.RebusBus(线程1):总线“ Rebus 2” 已启动[DBG] Rebus.Workers.ThreadPoolBased.ThreadPoolWorker(Rebus 2 worker 1):正在启动(基于线程池的)worker“ Rebus 2 worker 1” 是订户1按ENTER退出
以下订阅者:
class Subscriber1
{
static void Main()
{
var activator = new BuiltinHandlerActivator();
activator.Register(() => new Handler());
Configure.With(activator)
.Logging(l => l.ColoredConsole(minLevel: LogLevel.Debug))
.Transport(t => t.UseAzureServiceBus(Consts.ServiceBusConnectionString, Consts.Subscriber1))
.Options(o =>
{
o.SimpleRetryStrategy(maxDeliveryAttempts: 2,
errorQueueAddress: "poison");
o.Register<ITopicNameConvention>(c => new SimpleTopicNameConvention());
o.Decorate<IErrorHandler>(c => new MyErrorHandler(c.Get<IErrorHandler>()));
o.SetNumberOfWorkers(5);
o.SetMaxParallelism(10);
o.SetBackoffTimes(
TimeSpan.FromMilliseconds(100),
TimeSpan.FromMilliseconds(200),
TimeSpan.FromSeconds(1));
}).Start();
//if block 2 is commented, the issue doesn't happen
//block 2 start
var activator2 = new BuiltinHandlerActivator();
Configure.With(activator2)
.Transport(t => t.UseAzureServiceBus(Consts.ServiceBusConnectionString, "poison"))
.Routing(r =>
{
r.AddTransportMessageForwarder(async transportMessage =>
{
var sourceQueue =
transportMessage.Headers.TryGetValue(Headers.SourceQueue, out var result)
? result
: throw new ArgumentException($"Could not find '{Headers.SourceQueue}' header");
return ForwardAction.ForwardTo(sourceQueue);
});
})
.Start();
//block 2 end
activator.Bus.Subscribe<string>().Wait();
Console.WriteLine("This is Subscriber 1");
Console.WriteLine("Press ENTER to quit");
Console.ReadLine();
Console.WriteLine("Quitting...");
activator.Dispose();
activator2.Dispose();
}
}
如果上面的第2块被禁用,则不会发生此问题。
有什么主意吗?