NServicebus无法将失败的消息转发到错误队列

时间:2012-11-01 17:07:58

标签: msmq nservicebus

由于未配置ISendMessages,我遇到了将失败的消息转发到错误队列的问题。

我的app.config文件中有以下部分

<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />

<MessageForwardingInCaseOfFaultConfig ErrorQueue="nservicebus_error" />

<add key="ConnectivityRetryPeriod" value="30" />
<add key="FatalRetryCount" value="2" />
<add key="RetryFrequency" value="2" />

但是,当超过FatalRetryCount时,我得到以下异常

System.InvalidOperationException occurred
  Message=Could not forward failed message to error queue, reason: System.ArgumentException: NServiceBus.Unicast.Queuing.ISendMessages has not been configured. In order to avoid this exception, check the return value of the 'HasComponent' method for this type.
   at NServiceBus.ObjectBuilder.Spring.SpringObjectBuilder.NServiceBus.ObjectBuilder.Common.IContainer.Build(Type typeToBuild)
   at NServiceBus.ObjectBuilder.Common.CommonObjectBuilder.NServiceBus.ObjectBuilder.IBuilder.Build[T]()
   at NServiceBus.Faults.Forwarder.FaultManager.SendFailureMessage(TransportMessage message, Exception e, String reason).
  Source=NServiceBus.Core
  StackTrace:
       at NServiceBus.Faults.Forwarder.FaultManager.SendFailureMessage(TransportMessage message, Exception e, String reason)
  InnerException: System.ArgumentException
       Message=NServiceBus.Unicast.Queuing.ISendMessages has not been configured. In order to avoid this exception, check the return value of the 'HasComponent' method for this type.
       Source=NServiceBus.ObjectBuilder.Spring
       StackTrace:
            at NServiceBus.ObjectBuilder.Spring.SpringObjectBuilder.NServiceBus.ObjectBuilder.Common.IContainer.Build(Type typeToBuild)
            at NServiceBus.ObjectBuilder.Common.CommonObjectBuilder.NServiceBus.ObjectBuilder.IBuilder.Build[T]()
            at NServiceBus.Faults.Forwarder.FaultManager.SendFailureMessage(TransportMessage message, Exception e, String reason)

具体而言,此异常记录在NServiceBus.Faults.Forwarder命名空间中的FaultManager.cs中的以下lien中

Line where the error is thrown

这是App.Config部分和我使用的配置代码

App.Config sections

Config code

1 个答案:

答案 0 :(得分:0)

从NServiceBus支持团队解决了这个问题,当我明确调用.MsmqTransport()时,看起来ISendMessages已经注册了。我更新了配置代码以调用.MsmqTransport()并且FaultManager停止抛出此异常