質問

I've got a app.config configuration for Rebus and it works:

<configuration>
  <configSections>
    <section name="rebus" type="Rebus.Configuration.RebusConfigurationSection, Rebus" />
  </configSections>
  <rebus address="192.168.10.100" inputQueue="a.messages" errorQueue="a.error" workers="1" maxRetries="10">
    <endpoints>
      <add messages="ESB_Model" endpoint="a.messages@MyRemoteMachine" />
    </endpoints>
  </rebus>
</configuration>

After now I want to set the address and endpoint in code instead of configfile:

_adapter = new BuiltinContainerAdapter();

        _bus = Configure.With(_adapter)
            .Logging(l => l.None())
            .Transport(t => t.UseMsmq("a.messages@MyRemoteMachine", "a.error"))
            .MessageOwnership(d => d.FromRebusConfigurationSection())
            .CreateBus()
            .Start();

This is not accepted and I'm not sure how to set the IP-address. Any help would be welcome!

役に立ちましたか?

解決

I can see a couple of issues with your code, first one being that the two configurations are not equivalent.

The issue with the second configuration is that Rebus does not allow you to use a remote queue as your endpoint's input queue. Therefore, the @-syntax should not be used when defining the input queue.

Also, it seems you're mixing something up - a.messages seems to be your input queue, but it also seems that you want to use it (granted: on another machine) as the owner of all messages from ESB_Model. It might be correct, but it seems you're mixing it up a little bit.

Usually, each endpoint should have its own unique input queue, and endpoints should always receive their messages from a local queue. And you should probably never have two endpoints receiving messages from the same queue.

Lastly: Unless you really know what you're doing, please don't explicitly specify the IP address of your endpoint - Rebus will automatically use the input queue in combination with the machine name as the address - e.g. if an endpoint a.messages running on SomeMachine sends a message to another endpoint, the return address will automatically be set as a.messages@SomeMachine.

If you'd like some more inspiration, you can check out the samples: https://github.com/mookid8000/Rebus/tree/master/samples/Rebus.Samples - the pub/sub sample has some simple configurations that work fine and don't over-specify.

Hope that clears it up a little bit - please let me know if you need more help :)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top