如何在 RabbitMQ 的 MassTransit 中更改错误队列和交换的名称? [英] How to change names of error queues and exchanges in MassTransit for RabbitMQ?
本文介绍了如何在 RabbitMQ 的 MassTransit 中更改错误队列和交换的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在一个简单的配置中抛出一些异常,并注意到创建了一些交换和一个与错误相关的队列:
交流:
MassTransit:故障
MassTransit:Fault--ConsoleApp1:Program-YourMessage--
队列:
ReceiveEndPointQueue_error
如何更改或自定义上述命名?
Program.cs
:
公共静态类程序{公开课 YourMessage{公共字符串文本 { 获取;放;}}公共类 MyMessage{public int Number { 得到;放;}}公共静态异步任务 Main(params string[] args){var bus = Bus.Factory.CreateUsingRabbitMq(configuration =>{configuration.OverrideDefaultBusEndpointQueueName("DefaultBusEndpointQueue");configuration.Message(x =>{x.SetEntityName("YourMessageEntity");});configuration.Message(x =>{x.SetEntityName("MyMessageEntity");});var host = configuration.Host(new Uri("rabbitmq://localhost"), h =>{});configuration.ReceiveEndpoint(host, "ReceiveEndPointQueue", ep =>{ep.Handler(async context => throw new Exception("YourMessage"));ep.Handler(async context => await Console.Out.WriteLineAsync($"Received MyMessage: {context.Message.Number}"));});});等待 bus.StartAsync();await bus.Publish(new YourMessage{Text = "Hi"});等待 bus.Publish(new MyMessage {Number= 42});Console.WriteLine("按任意键退出");Console.ReadKey();等待 bus.StopAsync();}}
解决方案
直接引用 https://gitter.im/MassTransit/MassTransit
<块引用>Ehouarn Perret@ehouarn-perret5 月 30 日 20:14在使用 MassTransit 和 RabbitMQ 时,我仍在寻找一种方法来更改错误交换/队列的默认名称,在文档中找不到任何内容"克里斯帕特森@phatboyg5 月 30 日 20:31没有办法改变它们,它总是 queue_error"
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
:
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
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"
这篇关于如何在 RabbitMQ 的 MassTransit 中更改错误队列和交换的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文