我尝试在一个简单的配置中抛出一些异常,并注意到创建了一些交换和一个与错误相关的队列:
交流:
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();
}
}
2条答案
按热度按时间wtzytmuj1#
直接引用https://gitter.im/MassTransit/MassTransit
68bkxrlz2#
有一种方法可以更改错误队列名称,尽管不太优雅:
而且应该记住,这不会改变现有的拓扑结构,如果创建了一个具有默认名称的队列,它将保持相同的绑定。