Skip to content

Instantly share code, notes, and snippets.

@quooston
Created September 25, 2012 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quooston/3780286 to your computer and use it in GitHub Desktop.
Save quooston/3780286 to your computer and use it in GitHub Desktop.
Message versioning and inherritance?
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();
}
}
}
@phatboyg
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment