【问题标题】:nservicebus host won't remove messages from the queuenservicebus 主机不会从队列中删除消息
【发布时间】:2016-08-25 01:39:11
【问题描述】:

所以我让我的主机处理消息。它能做什么?获取包含电子邮件地址、正文和主题的消息。并使用 smtp 发送电子邮件。

所以在生产中,在我们的一个客户中,我看到队列中有 370 条消息。没有消息离开队列。只有新消息进入。

我看了看日志。看到的是这样的:

2016-04-28 17:35:10,243 [DAPROD01] [3] [] INFO : Failed to process message
System.Net.Mail.SmtpException: The operation has timed out.
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   at  EmailServiceHost.Utilities.EmailSender.Send(String recipient, String subject, String body) in e:\r-release\src\EmailServiceHost\Utilities\EmailSender.cs:line 24
   at NServiceBus.Unicast.HandlerInvocationCache.Invoke(Object handler, Object message, Dictionary`2 dictionary) in :line 0
   at NServiceBus.Pipeline.Behaviors.InvokeHandlersBehavior.DispatchMessageToHandlersBasedOnType(IBuilder builder, LogicalMessage toHandle, LoadedMessageHandlers loadedHandlers, BehaviorContext context) in :line 0
   at NServiceBus.Pipeline.Behaviors.InvokeHandlersBehavior.Invoke(BehaviorContext context, Action next) in :line 0
   at NServiceBus.Sagas.SagaPersistenceBehavior.Invoke(BehaviorContext context, Action next) in :line 0
   at NServiceBus.Pipeline.Behaviors.LoadHandlersBehavior.Invoke(BehaviorContext context, Action next) in :line 0
   at NServiceBus.Pipeline.Behaviors.CallbackInvocationBehavior.Invoke(BehaviorContext context, Action next) in :line 0
   at NServiceBus.Pipeline.Behaviors.ApplyIncomingMessageMutatorsBehavior.Invoke(BehaviorContext context, Action next) in :line 0
   at NServiceBus.Pipeline.Behaviors.ExtractLogicalMessagesBehavior.Invoke(BehaviorContext context, Action next) in :line 0
   at NServiceBus.Pipeline.Behaviors.ApplyIncomingTransportMessageMutatorsBehavior.Invoke(BehaviorContext context, Action next) in :line 0
   at NServiceBus.UnitOfWork.UnitOfWorkBehavior.Invoke(BehaviorContext context, Action next) in :line 0
2016-04-28 17:35:10,602 [DAPROD01] [48] [] ERROR: Message has failed FLR and will be moved to the configured error q, ID=ec40ebe5-90a5-4014-be42-a5f500877d2a.
2016-04-28 17:36:50,689 [DAPROD01] [48] [] INFO : Failed to process message
System.Transactions.TransactionAbortedException: The transaction has aborted.
   at System.Transactions.TransactionStatePromotedAborted.BeginCommit(InternalTransaction tx, Boolean asyncCommit, AsyncCallback asyncCallback, Object asyncState)
   at System.Transactions.CommittableTransaction.Commit()
   at System.Transactions.TransactionScope.InternalDispose()
   at System.Transactions.TransactionScope.Dispose()
   at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.Action() in :line 0

所以您注意到第一个错误包含 smtp 客户端的超时。 接下来的 200 个错误只说 Failed to process message。

消息没有从私有队列中出来。

【问题讨论】:

  • 消息是移动到错误队列还是留在输入队列中?
  • 我和汤姆在一起。如果消息一直失败,则应将它们移至错误队列 bij NServiceBus。有可能它们被拾取并再次移入队列,或者移入重试队列或错误队列。您对一级重试、二级重试以及错误和审核队列的设置是什么?
  • 他们没有进入错误队列。我得到了所有的默认设置(意思是 5 FLR,没有 SLR)。消息只是停留在队列中。
  • 所以我编写了这个小实用程序来从队列中提取消息并且它起作用了。现在的问题是 - 为什么 nservice 总线主机(它是一个 Windows 服务)停止工作而不是从队列中提取消息?有任何想法吗?我们在日志和事件查看器中什么都没有。谢谢!

标签: email smtp queue nservicebus msmq


【解决方案1】:

消息处理程序处理事务中的消息。当它在处理消息时收到异常时,事务会回滚,并将消息放回队列中。

您的消息处理程序似乎无法发送邮件。 smtp 服务器已关闭、不可用或防火墙禁止与它的连接。你得到的超时异常会导致事务回滚。

最终,NServiceBus 应该将一直失败的消息移动到错误队列中。我不知道这里不会发生什么。也许你只是等待的时间不够长?顺便说一句,我认为默认设置是 5 个 FLR 和 3 个 SLR。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-29
    • 2022-06-10
    • 2014-06-01
    • 2013-10-01
    • 2015-10-18
    相关资源
    最近更新 更多