How to set unique queue name for ActiveMQ in MassTransit?

Viewed 767

In StartUp of the project, I make the following settings for MassTransit.ActiveMQ. But when I run, it creates two queues for me, one is event-listener and the other is called Generation.

When I publish information, the information goes into the queues generated by the system.

But I want the information to be published inside queue event-listener that I set.

Please guide me

services.AddMassTransit(x =>
{
    x.AddConsumer<EventConsumer>();

    x.UsingActiveMq((context, cfg) =>
    {
        cfg.Host("localhost", h =>
        {  
            h.Username("admin");
            h.Password("admin");
        });

        cfg.ReceiveEndpoint("event-listener", e =>
        {
            e.ConfigureConsumer<EventConsumer>(context);
        });
    });
});
1 Answers

MassTransit will only create queues for configured consumers, or explicitly configured receive endpoints. In the code above, the only queue created would be called event-listener. For each message type consumed by the consumer, a topic is created and a virtual topic consumer is created so that the receive endpoint can consume messages of each type.

When messages are published, a topic is created for each published message type.

If you want to send a message directly to a queue, instead of publishing:

var provider = serviceProvider.GetRequiredService<ISendEndpointProvider>();

var endpoint = await provider.GetSendEndpoint(new Uri("queue:event-listener"));

await endpoint.Send(...);
Related