【问题标题】:How to change names of error queues and exchanges in MassTransit for RabbitMQ?如何在 MassTransit for RabbitMQ 中更改错误队列和交换的名称?
【发布时间】:2019-05-11 15:28:45
【问题描述】:

我尝试在一个简单的配置中抛出一些异常,并注意到创建了一些交换和一个与错误相关的队列:

交流:

  • MassTransit:Fault
  • MassTransit:Fault--ConsoleApp1:Program-YourMessage--

队列:

  • ReceiveEndPointQueue_error

如何更改或自定义上述名称?

Program.cs:

public static class Program
{
    public class YourMessage
    {
        public string Text { get; set; }
    }

    public class MyMessage
    {
        public int Number { get; set; }
    }

    public static async Task Main(params string[] args)
    {
        var bus = Bus.Factory.CreateUsingRabbitMq(configuration =>
        {
            configuration.OverrideDefaultBusEndpointQueueName("DefaultBusEndpointQueue");
            configuration.Message<YourMessage>(x =>
            {
                x.SetEntityName("YourMessageEntity");
            });
            configuration.Message<MyMessage>(x =>
            {
                x.SetEntityName("MyMessageEntity");
            });


            var host = configuration.Host(new Uri("rabbitmq://localhost"), h =>
            {
            });
            configuration.ReceiveEndpoint(host, "ReceiveEndPointQueue", ep =>
            {
                ep.Handler<YourMessage>(async context => throw new Exception("YourMessage"));
                ep.Handler<MyMessage>(async context => await Console.Out.WriteLineAsync($"Received MyMessage: {context.Message.Number}"));
            });
        });

        await bus.StartAsync(); 
        await bus.Publish(new YourMessage{Text = "Hi"});
        await bus.Publish(new MyMessage {Number= 42});
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await bus.StopAsync();
    }
}

【问题讨论】:

    标签: c# .net-core rabbitmq masstransit


    【解决方案1】:

    直接引用https://gitter.im/MassTransit/MassTransit

    Ehouarn Perret
    @ehouarn-perret
    May 30 20:14
    "I am still looking for a way to change the default names of Error Exchanges / Queues when using MassTransit with RabbitMQ, can't find anything in the documentation"
    
    Chris Patterson
    @phatboyg
    May 30 20:31
    "There isnt' a way to change them, it's always queue_error"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-09
      • 2015-04-26
      • 1970-01-01
      • 1970-01-01
      • 2014-05-21
      相关资源
      最近更新 更多