如何在masstransit中记录失败的消息? [英] How to log failed message in masstransit?

查看:91
本文介绍了如何在masstransit中记录失败的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种很好的解决方案来记录失败的消息,恰好在超过重试限制之后,而无需处理错误队列.到目前为止,我发现了什么:

I'm looking for a good solution to log failed message, right after retry limit is exceeded, without having a deal with error queue. What I've found so far:

  • 我可以从 InMemoryInboundMessageTracker 继承并覆盖 IsRetryLimitExceeded ,但是到目前为止,除了id之外,没有关于消息本身的任何信息.
  • 我可以实现 IInboundMessageInterceptor 并在 Pre/PostDispatch 中获取 IConsumeContext ,但目前尚无关于成功/失败的信息.
  • li>
  • I can inherit from InMemoryInboundMessageTracker and override IsRetryLimitExceeded, but at this point there no information about message itself except id.
  • I can implement IInboundMessageInterceptor and get IConsumeContext in Pre/PostDispatch, but at this point there no information about success/fail.

因此,作为解决方案,我可以在 PreDispatch 中获得 IConsumeContext 并将其放入某种缓存中,然后从 IsRetryLimitExceeded 中的缓存中取出它. em>超过重试限制时.

So as a solution, I can get IConsumeContext in PreDispatch put it in some sort of a cache then get it out of a cache in IsRetryLimitExceeded when retry limit is exceeded.

方法按以下顺序调用: IsRetryLimitExceeded-> PreDispatch-> PostDispatch

Methods are called in such order: IsRetryLimitExceeded -> PreDispatch -> PostDispatch

所以我找不到从缓存中删除成功处理的消息的好地方.

So I can't find a good place to remove successfully processed message from a cache.

我当然可以使用大小受限制的缓存,但是整个解决方案似乎很奇怪.

Of course I can use a cache with restricted size but this whole solution seems to be weird.

任何对此事的想法将不胜感激.

Any thoughts on this matter would be appreciated.

推荐答案

您可以在总线上实现并配置自己的消息重试跟踪,以便将失败的消息传递给您的实现.您可以委派给默认的重试跟踪器,然后拦截事件以便对它们采取行动,或者可以根据需要实施自己的重试跟踪.

You can implement and configure your own Message Retry Tracking on the bus, so that messages that are failed are passed through your implementation. You can delegate to the default retry tracker and just intercept the events so that you can act on them, or you can implement your own retry tracking if needed.

MessageTrackerFactory是用于配置的委托,我认为接口就在附近.

MessageTrackerFactory is the delegate for configuring, I think the interface is nearby.

这篇关于如何在masstransit中记录失败的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆