我正在使用MassTransit版本2.9.2与MSMQ。消息未被发送到错误队列
我正在测试错误处理,并期望过程尝试发送我的消息5次,然后将消息放入错误队列中。
消息正在重试5次,但随后消失。任何人都可以解释为什么消息没有被发送到错误队列。
我的消费:
public class OrderConsumer : Consumes<SAPOrder>.Context
{
public ISapServiceRepository SapServiceRepository { get; set; }
public void Consume(IConsumeContext<SAPOrder> message)
{
try
{
// Send the message to SAP
this.SapServiceRepository.SendOrder(message.Message);
}
catch (Exception ex)
{
throw;
}
}
}
我使用AutoFac注册服务总线和消费者。
protected override void Load(ContainerBuilder builder)
{
builder.Register(c => ServiceBusFactory.New(sbc =>
{
// other configuration options
sbc.UseMsmq(
configurator => configurator.VerifyMsmqConfiguration());
sbc.UseXmlSerializer();
sbc.ReceiveFrom("msmq://localhost/orders");
sbc.Subscribe(x => x.LoadFrom(c.Resolve<ILifetimeScope>()));
sbc.EnableMessageTracing();
sbc.UseLog4Net();
})).As<IServiceBus>()
.SingleInstance();
if (this.registerConsumers)
{
builder.RegisterAssemblyTypes(this.GetType().Assembly)
.Where(t => t.Implements<IConsumer>())
.PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies)
.AsSelf();
builder.RegisterType<SapServiceRepository>()
.As<ISapServiceRepository>()
.InstancePerLifetimeScope()
.WithProperty("Username", "xxxxxxxxxxxx")
.WithProperty("Password", "xxxxxxxxxxxx")
.WithProperty("CountryId", "xxxxxxxxxxx")
.WithProperty("UseRequestLogging", true)
.PropertiesAutowired(
PropertyWiringOptions.PreserveSetValues | PropertyWiringOptions.AllowCircularDependencies);
}
}
感谢