迁移到NService 4(4.0.4)后,我遇到了问题。当消息处理失败时,看起来整个NServiceBus正在停止并且没有做任何工作(来自MSMQ的消息不再被消耗)。 查看日志后,我发现了以下错误:
NServiceBus.log:
2013-10-02 17:49:31.5786 |致命| 110 |故障管理器无法处理ID为aa32dce1-f408-4f6d-b448-a24b0118ec27的失败消息System.InvalidOperationException:无法将失败的消息转发到错误队列' administration.worker @ localhost.Retries @ localhost'因为它无法找到。 ---> NServiceBus.Unicast.Queuing.QueueNotFoundException:无法向地址发送消息:[administration.worker @ localhost.Retries @ localhost] ---> System.Messaging.MessageQueueException:队列不存在或您没有足够的权限来执行操作。 在System.Messaging.MessageQueue.MQCacheableInfo.get_WriteHandle() 在System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS属性,ITransaction事务) 在System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS属性,IntPtr事务) 在System.Messaging.MessageQueue.SendInternal(Object obj,MessageQueueTransaction internalTransaction,MessageQueueTransactionType transactionType) at NServiceBus.Transports.Msmq.MsmqMessageSender.Send(TransportMessage message,Address address)在c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Transports \ Msmq \ MsmqMessageSender.cs:第60行 ---内部异常堆栈跟踪结束--- at NServiceBus.Transports.Msmq.MsmqMessageSender.Send(TransportMessage message,Address address)在c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Transports \ Msmq \ MsmqMessageSender.cs:第76行 at NServiceBus.Faults.Forwarder.FaultManager.SendFailureMessage(TransportMessage message,Exception e,Boolean serializationException)在c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Faults \ Forwarder \ FaultManager.cs:第48行 ---内部异常堆栈跟踪结束--- at NServiceBus.Faults.Forwarder.FaultManager.SendFailureMessage(TransportMessage message,Exception e,Boolean serializationException)在c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Faults \ Forwarder \ FaultManager.cs:第78行 at NServiceBus.Unicast.Transport.FirstLevelRetries.TryInvokeFaultManager(TransportMessage message,Exception exception)in c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Unicast \ Transport \ FirstLevelRetries.cs:line 71InnerExceptionNServiceBus.Unicast.Queuing.QueueNotFoundException:无法向地址发送消息:[administration.worker @ localhost.Retries @ localhost] ---> System.Messaging.MessageQueueException:队列不存在或您没有足够的权限来执行操作。 在System.Messaging.MessageQueue.MQCacheableInfo.get_WriteHandle() 在System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS属性,ITransaction事务) 在System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS属性,IntPtr事务) 在System.Messaging.MessageQueue.SendInternal(Object obj,MessageQueueTransaction internalTransaction,MessageQueueTransactionType transactionType) at NServiceBus.Transports.Msmq.MsmqMessageSender.Send(TransportMessage message,Address address)在c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Transports \ Msmq \ MsmqMessageSender.cs:第60行 ---内部异常堆栈跟踪结束--- at NServiceBus.Transports.Msmq.MsmqMessageSender.Send(TransportMessage message,Address address)在c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Transports \ Msmq \ MsmqMessageSender.cs:第76行 at NServiceBus.Faults.Forwarder.FaultManager.SendFailureMessage(TransportMessage message,Exception e,Boolean serializationException)在c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Faults \ Forwarder \ FaultManager.cs:line 48InnerExceptionSystem.Messaging.MessageQueueException (0x80004005):队列不存在或您没有足够的权限来执行操作。 在System.Messaging.MessageQueue.MQCacheableInfo.get_WriteHandle() 在System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS属性,ITransaction事务) 在System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS属性,IntPtr事务) 在System.Messaging.MessageQueue.SendInternal(Object obj,MessageQueueTransaction internalTransaction,MessageQueueTransactionType transactionType) at NServiceBus.Transports.Msmq.MsmqMessageSender.Send(TransportMessage message,Address address)在c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Transports \ Msmq \ MsmqMessageSender.cs:第60行
MsmqDequeueStrategy.log有很多:
2013-10-02 17:49:32.5579 |错误| 57 |处理消息时出错。 System.ObjectDisposedException:信号量已被释放。 在System.Threading.SemaphoreSlim.Release(Int32 releaseCount) 位于c:\ BuildAgent \ work \ d4de8921a0aabf04 \ src \ NServiceBus.Core \ Transports \ Msmq \ MsmqDequeueStrategy.cs中的NServiceBus.Transports.Msmq.MsmqDequeueStrategy.Action():第227行 在System.Threading.Tasks.Task.Execute()
FaultManager.log:
2013-10-02 17:49:31.5746 |致命| 110 |无法将失败的消息转发到错误队列' administration.worker @ localhost.Retries @ localhost'因为它无法找到。
我按如下方式启动NSB:
Configure.Serialization.Xml();
Configure.Features.Enable<TimeoutManager>();
Configure.Features.Enable<Sagas>();
var conf = Configure.With(assemblies)
.CustomConfigurationSource(new BusConfigSource(assemblies))
.DefineEndpointName(ConfigurationManager.AppSettings["InputQueue"])
.CastleWindsorBuilder(container)
.MessageForwardingInCaseOfFault()
.UseInMemoryTimeoutPersister()
.UseTransport<Msmq>()
.PurgeOnStartup(false)
.FileShareDataBus(WebConfigurationManager.AppSettings["NServiceBusFileShare"])
.UnicastBus()
.LoadMessageHandlers()
.MsmqSubscriptionStorage()
.CreateBus()
.Start(() => Configure.Instance.ForInstallationOn<Windows>().Install());
编辑:更多信息。 我在IIS中托管NSB。我发布,发送和处理邮件。
Web.config看起来像这样:
答案 0 :(得分:3)
问题在于你的初始化代码......
.DefineEndpointName(ConfigurationManager.AppSettings["InputQueue"])
我在您提供的Web.config的屏幕截图中没有看到,但根据错误,我猜你已将其定义为"administration.worker@localhost"
。这应该只是"administration"
。
端点名称和输入队列不是一回事。从您的端点名称开始,NServiceBus从那里推断出所有队列的名称。因此输入队列为{EndpointName}@localhost
。如果您正在运行具有附加工作线程的主节点,则工作线程的输入队列为{EndpointName}.Worker@localhost
。超时队列为{EndpointName}.Timeouts@localhost
等。
当然,您通常不必在NServiceBus.Host端点中定义端点名称,但看起来您在Web应用程序中是自托管的。
以下是有关文档NServiceBus Input Queue / Endpoint Name的更多信息。
答案 1 :(得分:0)
这是一个看起来很滑稽的地址:administration.worker @ localhost.Retries @ localhost
您可能需要在配置文件中添加:
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
并设置
<MessageForwardingInCaseOfFaultConfig ErrorQueue="error"/>
看一下错误处理示例(如果您安装了NServiceBus,它将在%ProgramFiles%\ Particular Software \ NServiceBus \ v4.0 \ NServiceBus \ Samples \ ErrorHandling中)
或在Github https://github.com/Particular/NServiceBus/tree/develop/Samples/ErrorHandling
希望这有帮助