Mapping messages from same assembly to different endpoints in Rebus using configsection

395 views Asked by At

I have my messagetypes in a shared assemby, Domain.Messages, and I need to map messages from that assembly to different endpoints using the RebusConfigurationSection in my .config file.

Like so:

<endpoints>
  <add messages="Domain.Messages.SubNamespaceA, Domain.Messages" endpoint="SubsystemA.input" />
  <add messages="Domain.Messages.SubNamespaceB, Domain.Messages" endpoint="SubsystemB.input" />
</endpoints>

That doesn't work but is it possible somehow or will I have to use an implementation of IDetermineMessageOwnership and handle the routing there?

1

There are 1 answers

0
mookid8000 On BEST ANSWER

It is currently not possible to map by namespace - current options are either a) map an entire assembly of messages, like so:

<endpoints>
    <add messages="Domain.Messages" endpoint="SubsystemA.input" />
</endpoints>

or b) explicitly map message types individually, like so:

<endpoints>
    <add messages="Domain.Messages.SubNamespaceA.MyMessage, Domain.Messages" endpoint="SubsystemA.input" />
</endpoints>

You can of course implement IDetermineMessageOwnership and do whichever funky lookup you feel like :)

Another option, which I would prefer, is to structure message assemblies so that each assembly of messages belongs to only one endpoint. This way you could do this:

<endpoints>
    <add messages="Domain.Messages.SubsystemA" endpoint="SubsystemA.input" />
    <add messages="Domain.Messages.SubsystemB" endpoint="SubsystemB.input" />
</endpoints>

and then never have to worry about (those particular) endpoint mappings again...