azureservicebusmasstransit

Adapting MassTransit to existing Azure ServiceBus Topology


Currently I am investigating if and how we can use MassTransit to replace NServiceBus. Aside from the wire compatibility (the serialization of the messages and headers), which seems doable, I am struggeling a bit with the topology (the setup of queues and topics).

For example, I have an Orders queue, which receives all kind of Order related commands, i.e. CreateOrder, CancelOrder. When I try to configure MassTransit, I am able to get an Orders queue created using

builder.Services.AddMassTransit(mt => {
  mt.AddConsumer<CreateOrderConsumer>();

  mt.UsingAzureServiceBus((context, cfg) => {
    cfg.Host("conn-string");

    cfg.ReceiveEndpoint("Orders", e => {
      e.ConfigureConsumers(context);
    });

  });
});

However, this also creates a Topic CreateOrder, with a single subscription "Orders" which will forward all messages to the "Orders" queue. Although this will work, having a topic for this is a change in the existing topology, and having a topic for a many-to-one communication (like sending a command instead of publishing an event) seems odd to me.

How can I configure MassTransit to only create the Orders queue, without the CreateOrder topic, and configure sending components using MassTransit to send to this queue directly (instead of sending it to the topic)?


Solution

  • e.ConfigureConsumeTopology = false

    Documentation