Azure service bus

55 views
Skip to first unread message

Jeff Posey

unread,
Aug 17, 2016, 6:44:17 PM8/17/16
to masstransit-discuss
I'm trying out using mass transit with azure service bus and have finally gotten a sample to work.

So this works:

        private static IPingResponse PerformSampleRequest2(IBusControl busControl, int i)
        {
            Console.WriteLine("Sending message " + i);
            var pong = busControl
                .CreatePublishRequestClient<IPingMessage, IPingResponse>(TimeSpan.FromSeconds(60), null)
                .Request(new PingMessage { Message = "Ping: " + i}).Result;
            return pong;
        }

but this doesn't:

        private static async Task<IPingResponse> PerformSampleRequest(IBusControl busControl, int i)
        {
            Task<IPingResponse> responseTask = null;

            Console.WriteLine("Sending message " + i);
            busControl.PublishRequest(new PingMessage
            {
                Message = "Ping " + i
            }, x =>
            {
                x.Timeout = TimeSpan.FromSeconds(30);
                responseTask = x.Handle<IPingResponse>();
            }).Wait();

            return await responseTask;
        }

the 2nd one times out waiting for a response. They both work using rabbit.

Anyone have any ideas why?

Chris Patterson

unread,
Aug 17, 2016, 7:33:28 PM8/17/16
to masstrans...@googlegroups.com
Well, you're using .Wait() in an async method, my guess is you're blocking the synchronization context of the app and it's all related to TPL craziness.

Change the .Wait() to await and see if that helps with your problem.


--
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/eb2a6a22-cede-447e-8c6d-fc2dc6c46046%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeff Posey

unread,
Aug 18, 2016, 10:12:02 AM8/18/16
to masstransit-discuss
I changed it from Wait() to await and I still get the timeout. Both methods work when using Rabbit, it's just the second one fails when using the Azure transport. I would have expected the same behavior regardless of the transport, and just trying to understand why they behave differently.

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

Chris Patterson

unread,
Aug 18, 2016, 11:10:20 AM8/18/16
to masstrans...@googlegroups.com
While the behavior is generally the same, the timeout is likely due to the threading differences between the RabbitMQ client and the Azure Service Bus client (the latter of which is async, whereas the RabbitMQ client does not yet have TPL support).


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.

Chris Patterson

unread,
Aug 18, 2016, 11:11:42 AM8/18/16
to masstrans...@googlegroups.com
You might also check your types, and ensure that your consumer is using the same type that is being published by the request. There is very limited support for message polymorphism in Azure Service Bus, so if you're publishing A and consuming IA, that may well be the difference. Also, make sure your consumer is responding with the appropriate types as well.



To post to this group, send email to masstransit-discuss@googlegroups.com.

Jeff Posey

unread,
Aug 22, 2016, 10:00:45 AM8/22/16
to masstransit-discuss
Hey Chris,

Yeah you were exactly right, in the consumer I was responding with PingResponse and in the client it's doing Handle<IPingResponse>.
I added a concrete type in my client and did Handle<PingResponse> and it started working. The interesting thing is I went back and removed the concrete class and changed it back to IPingResponse and it still worked. But maybe that was b/c the queues didn't get re-created and was already wired up to receive that response? 

Anyway, thanks for the help!
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,
Aug 22, 2016, 11:16:08 AM8/22/16
to masstrans...@googlegroups.com
Yeah, you likely already had the subscription setup in the topic. If you removed the topics and queues and started from scratch it probably would not work again.


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+unsubscribe...@googlegroups.com.

To post to this group, send email to masstrans...@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.
Reply all
Reply to author
Forward
0 new messages