2013-03-16 49 views
1

我想在同一個進程/ AppDomain中使用Rebus作爲內部總線。同樣的過程訂閱在Rebus中是不可能的

我已經修改了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目前沒有配置wi一個端點映射機制「,我應該在訂閱時指定一個目的地或更改配置。我寧願使用配置,但如何?

回答

0

看來你需要指定滷麪可以查找端點映射又名消息所有權在你的app.config:

.MessageOwnership(o => o.FromRebusConfigurationSection()) 

實際上,我認爲錯誤消息解釋了這一點,如果我沒有記錯,它甚至提供必要的C#和XML,可以解決這種情況;)

+0

謝謝......我是......盲目:) – Lybecker 2013-03-16 11:06:58