3

I'm using Masstransit dotnet core v6.3.1 with RabbitMQ v3. My case is sending request from api gateway to other services. Services consume by topics and Gateway using different topics per request. I'm trying to use request/response with masstransit. But requestClient declared exhange type to fanout. And I cant change the type. I want to use different routingKey per request with request/response. How can I do this?

I have used in gateway: (startup.cs)

cfg.AddRequestClient<ISimpleRequest>();

(Custom Controller)

await client.GetResponse<ISimpleResponse>(new { Data="test request"});

I have used in other services(startup):

cfg.ReceiveEndpoint("TestGateway", ep =>
{
    ep.Consumer(() => new SimpleConsumer(context));
});

(Custom Consumer)

await client.RespondAsync<ISimpleResponse>(new { Data="test response"});

Also I tried to declare exchange in rabbitmq first. After I created request from clientFactory with exchange Uri. But I had an error like " ...received 'fanout' but current is 'topic'."

ofaruksahin
  • 31
  • 1
  • 2

1 Answers1

1

There is a sample on using a direct exchange, topic exchanges are similar but support wildcard semantics. I'd suggest reviewing it to get more details on how to configure topology with RabbitMQ using MassTransit.

Sample

There is also documentation on how to setup routing keys with exchange types.

Chris Patterson
  • 28,659
  • 3
  • 47
  • 59
  • I again reviewed docs and I used topics topology like your sample-direct. But I think this is not my solution, my problem still continues in multithreading. I can't wait and catch the response after publishing the message. Is there any way to use requestClient in topics topology? Thanks for helping. – ofaruksahin Jun 04 '20 at 07:24