Вопрос

I am trying to use Rebus as internal bus within the same process/AppDomain.

I have modified the Pub/Sub sample and added a SameProcessHandler:

class SameProcessHandler : IHandleMessages<string>
{
    public void Handle(string message)
    {
        Console.WriteLine("Same Process: {0}", message);
    }
}

Added the subscription after the bus start:

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>();

Finally added the destination queue (not sure it is needed):

<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>

But I getting error "Rebus is currently not configured with an endpoint mapping mechanism" and I should either specify a destination at subscription time or change the config. I rather use the config, but how?

Это было полезно?

Решение

Seems you need to specify that Rebus can look up endpoint mapping a.k.a. message ownership in your app.config:

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

Actually, I think the error message explains this, and if I remember correctly, it even provides the necessary C# and XML that can resolve the situation ;)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top