如何查看Akka死信

编程入门 行业动态 更新时间:2024-10-10 11:27:33
本文介绍了如何查看Akka死信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个执行一些基本操作并且似乎正常工作的Actor-但是我经常在日志中看到以下内容

I've created an Actor that performs some basic operations and appears to be working correctly - however I'm seeing the following show up in my logs regularly

[INFO] [05/28/2014 14:24:00.673] [application-akka.actor.default-dispatcher-5] [akka://application/deadLetters] Message [akka.actor.Status$Failure] from Actor[akka://application/user/trigger_worker_supervisor#-2119432352] to Actor[akka://application/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

我想实际查看失败的内容,以确定确切地抛出失败,但是我不太清楚如何查看它们。

I would like to actually view the contents of the Failure to establish what exactly is throwing a Failure, however I can't quite figure out how to view them.

通读Akka文档,其中提到了如何禁用日志中的死信警告,而不是如何实际编写处理程序来处理它们。

Reading through the Akka documentation it mentions how to disable the dead-letter warning in the logs, but not how to actually write a handler to process them.

有没有一种简单的方法可以实际捕获发送到死信的任何内容?

Is there a simple way to actually catch anything sent to dead-letters?

推荐答案

如@wingedsubmariner的评论中所述,您可以订阅 DeadLetter 事件在发生死信时得到通知,并能够以更自定义的方式对这种情况做出反应。为了订阅,代码如下所示:

As mentioned in the comment by @wingedsubmariner, you can subscribe to the DeadLetter event on the main system EventStream to be notified when deadletters happen and be able to react to that situation in a more custom manner. In order to subscribe, the code would look like this:

context.system.eventStream.subscribe(myListenerActorRef, classOf[DeadLetter])

然后,该侦听器演员的接收看起来像这样:

Then, the receive for that listener actor could look something like this:

def receive = { case DeadLetter(msg, from, to) => //Do my custom stuff here }

DeadLetter 类是:

case class DeadLetter(message: Any, sender: ActorRef, recipient: ActorRef)

更多推荐

如何查看Akka死信

本文发布于:2023-11-25 21:11:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631364.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:死信   Akka

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!