我正在尝试将Rebus用作同一进程/ AppDomain中的内部总线。
我修改了Pub/Sub sample并添加了SameProcessHandler:
class SameProcessHandler : IHandleMessages<string>
{
public void Handle(string message)
{
Console.WriteLine("Same Process: {0}", message);
}
}
在巴士开始后添加订阅:
Configure.With(adapter)
.Logging(l => l.ColoredConsole(minLevel: LogLevel.Warn))
.Transport(t => t.UseMsmqAndGetInputQueueNameFromAppConfig())
.Subscriptions(s => s.StoreInXmlFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "rebus_subscriptions.xml")))
.CreateBus()
.Start();
adapter.Bus.Subscribe<string>();
最后添加了目标队列(不确定是否需要):
<rebus inputQueue="pubsubsample.publisher.input"
errorQueue="pubsubsample.publisher.error"
workers="1" maxRetries="5">
<endpoints>
<!-- brute force ownership - all core .NET types are owned by our publisher :) -->
<add messages="mscorlib" endpoint="pubsubsample.publisher.input"/>
</endpoints>
</rebus>
但是我收到错误“Rebus当前没有配置端点映射机制”,我应该在订阅时指定目的地或更改配置。我宁愿使用配置,但是如何?
答案 0 :(得分:0)
似乎你需要指定Rebus可以在app.config中查找端点映射a.k.a.消息所有权:
.MessageOwnership(o => o.FromRebusConfigurationSection())
实际上,我认为错误信息解释了这一点,如果我没记错的话,它甚至提供了可以解决问题的必要C#和XML;)