Azure Service Bus and Message Contracts

41 views
Skip to first unread message

Long Mai

unread,
May 7, 2017, 10:05:05 PM5/7/17
to masstransit-discuss
Hey,

I simplified a scenario that it is doing something I wasn't expecting. Am I understanding correctly how MT should work? If so, is this supported in ASB?

public class MyMessageEvent : MyMessage
{
public string Text { get; set; }
}

public interface MyMessage
{
string Text { get; }
}

...

bus.Publish(new MyMessageEvent { Text = "Test" }); //Expecting to publish to MyMessage topic??, but it is publishing to MyMessageEvent topic

bus
.Publish<MyMessage>(new MyMessageEvent { Text = "Test" }); //Publishes to MyMessage topic as expected, but not sure I want to do this for the versioning scenario where the concrete class implements multiple interfaces (interface per version).

Chris Patterson

unread,
May 8, 2017, 12:55:21 AM5/8/17
to masstrans...@googlegroups.com
Service bus is limited right now, so you need to do the latter. 

A later version of MT will support the inheritance chain properly on service bus.


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/fa7e1917-3972-4666-a1ac-6a92f589a0f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Long Mai

unread,
May 8, 2017, 8:19:15 AM5/8/17
to masstransit-discuss
Thanks Chris.

Something I'm considering is possibly contributing if time allows for it in the next month and you think the scope of impact is minimal. I may need a little guidance if this is something you think you would consider delegating unless this is something being worked on now or soon. 

My current implementation that I'm leaning towards is this. I would, of course, use reflection to get the base types. For each base type, create its own subscription that autoforwards it to its own topic, creating the topics. In my example shared earlier, we would have a topic MyMessageEvent that has a subscription MyMessage that auto forwards to MyMessage topic. I assume it should deserialize without issues to the appropriate contracts. I would need to create the topics for each base types and set up the autoforwarding.

On Sunday, May 7, 2017 at 11:55:21 PM UTC-5, Chris Patterson wrote:
Service bus is limited right now, so you need to do the latter. 

A later version of MT will support the inheritance chain properly on service bus.

On Sun, May 7, 2017 at 7:05 PM, Long Mai <long...@gmail.com> wrote:
Hey,

I simplified a scenario that it is doing something I wasn't expecting. Am I understanding correctly how MT should work? If so, is this supported in ASB?

public class MyMessageEvent : MyMessage
{
public string Text { get; set; }
}

public interface MyMessage
{
string Text { get; }
}

...

bus.Publish(new MyMessageEvent { Text = "Test" }); //Expecting to publish to MyMessage topic??, but it is publishing to MyMessageEvent topic

bus
.Publish<MyMessage>(new MyMessageEvent { Text = "Test" }); //Publishes to MyMessage topic as expected, but not sure I want to do this for the versioning scenario where the concrete class implements multiple interfaces (interface per version).

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
May 8, 2017, 10:11:42 AM5/8/17
to masstrans...@googlegroups.com
That's already in the /develop branch of MT, so nothing to contribute. IT just hasn't be released yet.

On Mon, May 8, 2017 at 5:19 AM, Long Mai <long...@gmail.com> wrote:
Thanks Chris.

Something I'm considering is possibly contributing if time allows for it in the next month and you think the scope of impact is minimal. I may need a little guidance if this is something you think you would consider delegating unless this is something being worked on now or soon. 

My current implementation that I'm leaning towards is this. I would, of course, use reflection to get the base types. For each base type, create its own subscription that autoforwards it to its own topic, creating the topics. In my example shared earlier, we would have a topic MyMessageEvent that has a subscription MyMessage that auto forwards to MyMessage topic. I assume it should deserialize without issues to the appropriate contracts. I would need to create the topics for each base types and set up the autoforwarding.

On Sunday, May 7, 2017 at 11:55:21 PM UTC-5, Chris Patterson wrote:
Service bus is limited right now, so you need to do the latter. 

A later version of MT will support the inheritance chain properly on service bus.

On Sun, May 7, 2017 at 7:05 PM, Long Mai <long...@gmail.com> wrote:
Hey,

I simplified a scenario that it is doing something I wasn't expecting. Am I understanding correctly how MT should work? If so, is this supported in ASB?

public class MyMessageEvent : MyMessage
{
public string Text { get; set; }
}

public interface MyMessage
{
string Text { get; }
}

...

bus.Publish(new MyMessageEvent { Text = "Test" }); //Expecting to publish to MyMessage topic??, but it is publishing to MyMessageEvent topic

bus
.Publish<MyMessage>(new MyMessageEvent { Text = "Test" }); //Publishes to MyMessage topic as expected, but not sure I want to do this for the versioning scenario where the concrete class implements multiple interfaces (interface per version).

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Long Mai

unread,
May 8, 2017, 9:29:46 PM5/8/17
to masstransit-discuss
That's weird. I tested this scenario with the /develop branch of MT, but it doesn't work as I expect it to. Here is additional code to give more context. I can see this also working if I explicitly specify the topic instead of using the generic typed subscription endpoint method; however, I don't think I would expect to use it in that way.

public class MyMessageConsumer : IConsumer<MyMessageV1>
   {
       public async Task Consume(ConsumeContext<MyMessageV1> context)
       {
           await Console.Out.WriteLineAsync(context.Message.Text);
       }
   }
...

sbc.SubscriptionEndpoint<MyMessageV1>(host, "consumer1", ep => { ep.Consumer<MyMessageConsumer>(); });


    public class MyMessageConsumer : IConsumer<MyMessageV1>
    {
        public async Task Consume(ConsumeContext<MyMessageV1> context)
        {
            await Console.Out.WriteLineAsync(context.Message.Text);
        }
    }



On Monday, May 8, 2017 at 9:11:42 AM UTC-5, Chris Patterson wrote:
That's already in the /develop branch of MT, so nothing to contribute. IT just hasn't be released yet.
On Mon, May 8, 2017 at 5:19 AM, Long Mai <long...@gmail.com> wrote:
Thanks Chris.

Something I'm considering is possibly contributing if time allows for it in the next month and you think the scope of impact is minimal. I may need a little guidance if this is something you think you would consider delegating unless this is something being worked on now or soon. 

My current implementation that I'm leaning towards is this. I would, of course, use reflection to get the base types. For each base type, create its own subscription that autoforwards it to its own topic, creating the topics. In my example shared earlier, we would have a topic MyMessageEvent that has a subscription MyMessage that auto forwards to MyMessage topic. I assume it should deserialize without issues to the appropriate contracts. I would need to create the topics for each base types and set up the autoforwarding.

On Sunday, May 7, 2017 at 11:55:21 PM UTC-5, Chris Patterson wrote:
Service bus is limited right now, so you need to do the latter. 

A later version of MT will support the inheritance chain properly on service bus.

On Sun, May 7, 2017 at 7:05 PM, Long Mai <long...@gmail.com> wrote:
Hey,

I simplified a scenario that it is doing something I wasn't expecting. Am I understanding correctly how MT should work? If so, is this supported in ASB?

public class MyMessageEvent : MyMessage
{
public string Text { get; set; }
}

public interface MyMessage
{
string Text { get; }
}

...

bus.Publish(new MyMessageEvent { Text = "Test" }); //Expecting to publish to MyMessage topic??, but it is publishing to MyMessageEvent topic

bus
.Publish<MyMessage>(new MyMessageEvent { Text = "Test" }); //Publishes to MyMessage topic as expected, but not sure I want to do this for the versioning scenario where the concrete class implements multiple interfaces (interface per version).

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
May 9, 2017, 7:17:45 AM5/9/17
to masstrans...@googlegroups.com
Doesn't work with subscription endpoint. Only receive endpoint. 

__
Chris Patterson

From: masstrans...@googlegroups.com <masstrans...@googlegroups.com> on behalf of Long Mai <long...@gmail.com>
Sent: Monday, May 8, 2017 8:29:45 PM
To: masstransit-discuss
Subject: Re: [masstransit-discuss] Azure Service Bus and Message Contracts
 
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Long Mai

unread,
May 9, 2017, 8:24:13 AM5/9/17
to masstransit-discuss
That still didn't work for me. This is what ends up happening..

The producer publishes to the MyMessageEvent topic (concrete class) whereas the consumer has a queue receiving from an autoforward subscription on the MyMessageV1 topic (MyMessageEvent implements MyMessageV1).
Reply all
Reply to author
Forward
0 new messages