[英]How to change names of error queues and exchanges in MassTransit for RabbitMQ?
I tried to throw some exceptions in a simple configuration and noticed the creation of a few exchanges and one queue related to errors: 我试图在一个简单的配置中抛出一些异常,并注意到创建了一些与错误相关的交换和一个队列:
Exchanges: 交流:
MassTransit:Fault
MassTransit:Fault--ConsoleApp1:Program-YourMessage--
Queues: 队列:
ReceiveEndPointQueue_error
How can I change or customize the naming of those above? 如何更改或自定义以上名称?
Program.cs
: 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();
}
}
Directly quoted https://gitter.im/MassTransit/MassTransit 直接引用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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.