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?"
});
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------