Duplication of IHandleMessage implementation #1220
Replies: 1 comment
-
|
Hi @Cattivik73 , did you close the discussion because you found a solution? In case you didn't, here's a way to solve your problem 🙂 If I understand you correctly, you would like to have a message type record MyMessage(string Text);in two different assemblies, so your Rebus instances don't have to share a reference to a shared NuGet package/DLL. Doing that is pretty simple with Rebus: You can just turn on "custom type names", this way forcing Rebus to call services.AddRebus(
configure => configure
.(...)
.Serialization(s => s.UseCustomMessageTypeNames()
.AddWithCustomName<MyMessage>("messages/mymessage")
.AddWithCustomName<AnotherMessage>("messages/anothermessage"))
.(...)
);which in this case forcec Rebus to put "messages/mymessage" as the type name for services.AddRebus(
configure => configure
.(...)
.Serialization(s => s.UseCustomMessageTypeNames()
.AddWithCustomName<Messages_MyMessage>("messages/mymessage")
.AddWithCustomName<Messages_AnotherMessage>("messages/anothermessage"))
.(...)
);and Rebus will then deserialize the message as You can check out this code for an example on how it works: https://github.com/rebus-org/Rebus/blob/master/Rebus.Tests/Examples/ShowHowToAvoidSharingMessageDllsAcrossProcesses.cs |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I din't find a way to have different classes in different assemblies that implement the same 'kind' of message, I tried with same name and same namespace but nothing. It seems that your implementation reuired that you have a specific assembly in which define the implementation of IHandleMessage . I understand the motivation but this can be a bond from architectural point of view, because it force a reference to Rebus dll. Normally in cominication framework like WCF, or webapi the proxies can be duplicated in different assemblies and this approach, 'less purist' bring a lot of advantages in references.
Beta Was this translation helpful? Give feedback.
All reactions