v4 Request/Response Newbie

61 views
Skip to first unread message

Jordan

unread,
Aug 16, 2017, 10:16:46 AM8/16/17
to masstransit-discuss
Hey everyone,

I'm switching to MassTransit from RawRabbit, and I can't seem to get the request/response up and working. Everything is going through the "ignore" exchange and not hitting my handler.
Am I missing something/doing something wrong?

----------------------------------------------------------------------------------------------------------------------------------------------------
    public class Program
    {
        private static IBusControl _bus;

        static void Main(string[] args)
        {
            _bus = Bus.Factory.CreateUsingRabbitMq(config =>
            {
                var host = config.Host(new Uri("rabbitmq://localhost"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                config.PrefetchCount = 50;
                config.Durable = true;

                var queueName = Assembly.GetEntryAssembly().FullName.Split(',')[0];

                config.ReceiveEndpoint(host, queueName, endpoint =>
                {
                    var handlerType = typeof(MyQHandler);

                    endpoint.Consumer(handlerType, t => new MyQHandler());
                });
            });

            _bus.Start();

            var requestClient = _bus.CreateRequestClient<MyQuery, MyQueryResponse>(new Uri(_bus.Address, "requestResponse"), TimeSpan.FromSeconds(5));

            var response = requestClient.Request<MyQuery, MyQueryResponse>(new MyQuery{Question = "did you get me?"}).Result;

            Console.WriteLine(response.Answer);
        }
    }
    
    public class MyQuery
    {
        public string Question { get; set; }
    }

    public class MyQueryResponse
    {
        public string Answer { get; set; }
    }

    public class MyQHandler : IConsumer<MyQuery>
    {
        public async Task Consume(ConsumeContext<MyQuery> context)
        {
            Console.WriteLine(context.Message.Question);

            await context.RespondAsync(new MyQueryResponse
            {
                Answer = "who cares?"
            });
        }
    }
----------------------------------------------------------------------------------------------------------------------------------------------------

Chris Patterson

unread,
Aug 16, 2017, 11:05:34 AM8/16/17
to masstrans...@googlegroups.com
First, you need to make sure your request client is sending requests to the queueName you specified for the receive endpoint.

Second, you can register your consumer using a simple, "endpoint,Consumer<MyQHandler>()" instead of the type syntax you're using.


--
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/8c6a4c3a-6970-43e6-8644-f8cb1dacdf9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jordan

unread,
Aug 16, 2017, 11:12:19 AM8/16/17
to masstransit-discuss
Hi Chris,

Thanks for the quick response.

The issue I am seeing is that the messages are being sent to the "ignore_skipped" exchange that is created, and ending up in the "ignore_skipped" queue. I am not sure what the reasoning is behind this.

Also, I am using the factory consumer method as I will be resolving some handlers in my actual application that are registered in the IoC container.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Aug 16, 2017, 11:13:28 AM8/16/17
to masstrans...@googlegroups.com
Hmm, I think that "ignore" is a bug in the current released preview of v4. I should publish another one which fixes it.


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.

Jordan

unread,
Aug 16, 2017, 11:14:36 AM8/16/17
to masstransit-discuss
Ok, thanks for the clarification. I'll keep an eye out for updates.
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.

Alexey Zimarev

unread,
Aug 16, 2017, 1:59:49 PM8/16/17
to masstransit-discuss
You can use 3.5.7, it works fine. The request-response sample works fine https://github.com/MassTransit/Sample-RequestResponse

Jordan

unread,
Aug 16, 2017, 2:06:55 PM8/16/17
to masstransit-discuss
Sorry I forgot to mention that all of the services I am going to build out will be utilizing .NET Core.

Chris Patterson

unread,
Aug 16, 2017, 4:24:17 PM8/16/17
to masstrans...@googlegroups.com
The updated packages were pushed earlier today.

--
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.

Jordan

unread,
Aug 18, 2017, 8:59:02 AM8/18/17
to masstransit-discuss
Thank you for the help Chris. Everything is working as expected now.


On Wednesday, August 16, 2017 at 4:24:17 PM UTC-4, Chris Patterson wrote:
The updated packages were pushed earlier today.
On Wed, Aug 16, 2017 at 11:06 AM, Jordan <jordan....@bluesombrero.com> wrote:
Sorry I forgot to mention that all of the services I am going to build out will be utilizing .NET Core.

On Wednesday, August 16, 2017 at 1:59:49 PM UTC-4, Alexey Zimarev wrote:
You can use 3.5.7, it works fine. The request-response sample works fine https://github.com/MassTransit/Sample-RequestResponse

--
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.
Reply all
Reply to author
Forward
0 new messages