【发布时间】:2016-12-28 00:07:33
【问题描述】:
使用 MSMQ 启用集中式存储时,还有什么需要更改的吗?这是我所拥有的,但代码不会完全加载。如果我禁用集中式存储,将按预期工作。
_messageActivator = new BuiltinHandlerActivator();
_messageActivator.Register<PosOnlineHandler>(() => new PosOnlineHandler(WriteOutputAsync));
_messageActivator.Register<PumpDownHandler>(() => new PumpDownHandler(WriteOutputAsync));
_messageActivator.Register<MetersRequestHandler>(() => new MetersRequestHandler(WriteOutputAsync, _messageActivator.Bus));
_messageActivator.Register<CreditAuthorizationHandler>(() => new CreditAuthorizationHandler(WriteOutputAsync, _messageActivator.Bus));
Configure.With(_messageActivator)
.Transport(t => t.UseMsmq("consumerServiceQueue"))
.Routing(r => r.TypeBased()
.Map<PumpDownEvent>("publisherServiceQueue")
.Map<PosOnlineEvent>("publisherServiceQueue")
.Map<MetersResponse>("publisherServiceQueue")
.Map<CreditAuthorizationResponse>("publisherServiceQueue"))
.Subscriptions(s => s.StoreInSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=test;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", "RebusSubscriptions", true, true))
.Start();
_messageActivator.Bus.Subscribe<PumpDownEvent>().Wait();
_messageActivator.Bus.Subscribe<PosOnlineEvent>().Wait();
谢谢。 斯科特 C.
【问题讨论】:
-
“代码不会完全加载”是什么意思?
-
抱歉,它挂在 Subscriber().Wait() 上。 .....,我看到 MessageBus 示例使用集中式 MSMQ 存储,所以我稍后会对其进行测试,看看是否得到相同的结果。
-
在 30 秒或 1 分钟后没有超时?
-
不。启用 isCentralized 后,它只会继续挂在那里。 MessageBus 示例运行良好,因此这显然是我在代码中所做的事情。我下载了 Rebus 代码以便调试,但还不能构建 Rebus 解决方案。
-
是应用程序初始化时执行的代码吗?还是发生在 WPF 线程或 ASP.NET 请求线程上?
标签: rebus