Created
September 25, 2012 06:27
-
-
Save quooston/3780286 to your computer and use it in GitHub Desktop.
Message versioning and inherritance?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MassTransit; | |
namespace ConsoleApplication8 | |
{ | |
interface IA { string Name { get; set; } } | |
interface IB : IA { string LastName { get; set; } } | |
interface IC : IB { int Age { get; set; } } | |
class HelloMessage : IC | |
{ | |
public string Name { get; set; } | |
public string LastName { get; set; } | |
public int Age { get; set; } | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var bus = ServiceBusFactory.New(sbc => | |
{ | |
sbc.UseMsmq(); | |
sbc.VerifyMsmqConfiguration(); | |
sbc.ReceiveFrom("msmq://localhost/test_queue"); | |
sbc.Subscribe(subs => | |
{ | |
subs.Handler<IA>(msg => Console.WriteLine(msg.Name)); | |
subs.Handler<IB>(msg => Console.WriteLine("specialHandler:" + msg.LastName)); | |
subs.Handler<IC>(msg => Console.WriteLine("specialHandler2:" + msg.Age)); | |
}); | |
}); | |
bus.Publish(new HelloMessage | |
{ | |
Name = "Bob", | |
LastName = "Smithers", | |
Age = 45 | |
}); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not POSITIVE, but I think the interfaces need to be public in order for the proxy to generate them, I could be wrong though.
Add some log4net logging and see why the serializer is unable to deserialize your message.