I am not able to figure out on how to specify the Exchange
and Queue
in my GetSendEndpoint())
task when sending / publishing messages?
As per MassTransit documentation https://masstransit-project.com/usage/producers.html#send you can specify the exchange and queue like
GetSendEndpoint(new Uri("queue:input-queue"))
However, I can only do one or the other?
Is there an alternative way of sending with exchange and queue specified?
I am doing this in Asp.Net Core so here are my configuration:
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddMassTransit();
services.AddSingleton(p => Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.Host("rabbitmq://localhost", h =>
{
h.Username("admin");
h.Password("admin");
});
}));
services.AddSingleton<IBus>(p => p.GetRequiredService<IBusControl>());
services.AddSingleton<IHostedService, BusService>();
}
And this is how send the message
var endpoint = await _bus.GetSendEndpoint(new Uri(queue:Test.Queue));
await endpoint.Send(new Message()
{
Text = "This is a test message"
});
As you can see I can only specify the queue name.