So I have two separate applications that I want to send messages between. I happen to be using NServiceBus, but that shouldn't really matter. How do I send a message from application A to application B and have them both be aware of the same contract?
So app A has a class SecretMessage...
public class SecretMessage : IMessage
{
public string Title { get; set; }
public string Body { get; set; }
}
This is the object that will be serialized and sent over the wire to app B.
Now in app B, how do I listen for messages that are of that type and then be able to de-serialze them to the same class? So I can use the data as it was sent, without this being a maintenance nightmare.
Does app B just have to have a copy of the class? Should this be handled through a shared dll of message classes that each app has a reference to (I hope not)? Should they be recreated in each app as completely separate DTO's with the same properties?
Am I missing something here?
It may not be the answer you want but there are very few silver bullets here.
You've really only got a few choices, and as such then depends on the level of functionality and type-hardening you want in your message classes:
Those really are the only choices. IMHO #2 then #1 in that order are typically the most useful patterns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With