1
votes

We migrated to .NET Core and we run a bunch of services using the dotnet CLI. After migrating, all our temporary queues are named <hostname>_dotnet_bus....

This is a bit annoying as it's quite difficult to figure out which service some of the error and skipped messages are coming from.

The way I see, there are two options:

  1. Provide a way to override the default behaviour through Configurator interfaces.
  2. Change the default behaviour when targeting .NET Standard.

The second options is dead simple and it's my current approach for a local build:

https://github.com/MassTransit/MassTransit/commit/16b884cf6abd08eb8f699667a22fc5e7542bba77

Should this be treated like an issue and raised on MassTransit's Github issue tracker? Thoughts?

1

1 Answers

2
votes

I think Endpoint Definitions should do the trick.

class YourAssemblyEndpointDefinition :
    DefaultEndpointDefinition
{
    public HubEndpointDefinition()
        : base(true)
    {
    }

    public override string GetEndpointName(IEndpointNameFormatter formatter)
    {
        return formatter.TemporaryEndpoint($"{typeof(YourType).Assembly.GetName()}");
    }
}

And then you can use it in the endpoint registration like so:

configurator.ReceiveEndpoint(new YourAssemblyEndpointDefinition(), ...)

you can see it in use here: https://github.com/MassTransit/MassTransit/blob/develop/src/MassTransit.SignalR/MassTransitSignalRConfigurationExtensions.cs

UPDATED

If you want to customize the bus name for req/resp, then you can use this override:

return Bus.Factory.CreateUsingRabbitMq(cfg =>
{
    cfg.OverrideDefaultBusEndpointQueueName("your_assembly_name")

    // your other config
});