我试图在同一进程/AppDomain内使用Rebus作为内部总线。
我已经修改了Pub/Sub示例并添加了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目前没有配置端点映射机制",我应该在订阅时指定目的地或更改配置。我宁愿使用配置,但如何使用?
似乎您需要指定Rebus可以在app.config中查找端点映射(即消息所有权):
.MessageOwnership(o => o.FromRebusConfigurationSection())
实际上,我认为错误消息解释了这一点,如果我没记错的话,它甚至提供了必要的c#和XML来解决这种情况;)