加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 处理Akka actor绑定邮箱MessageQueueAppendFailedExcep

发布时间:2020-12-16 18:27:50 所属栏目:安全 来源:网络整理
导读:为了避免OOM,我使用共享的自定义调度程序限制了我的一些Akka 1.1.3 actor的邮箱大小.例如: object Static { val dispatcher = Dispatchers.newExecutorBasedEventDrivenWorkStealingDispatcher( "customDispatcher",1000,BoundedMailbox(capacity = 10) )}c
为了避免OOM,我使用共享的自定义调度程序限制了我的一些Akka 1.1.3 actor的邮箱大小.例如:

object Static {
    val dispatcher = Dispatchers.newExecutorBasedEventDrivenWorkStealingDispatcher(
        "customDispatcher",1000,BoundedMailbox(capacity = 10)
    )
}

class MyActor extends Actor {
    self.dispatcher = Static.dispatcher
    ...
}

我想对邮箱溢出做出反应,这样我就可以向上游生产者发出暂停消息(旁注:遗憾的是看起来像actor.stop(),等等,而actor.start()会抛出一个ActorStartException).在队列填满和队列耗尽之间可以接受一些数据丢失.

Akka关于Dispatchers的章节说

When trying to send a message to the Actor it will throw a
MessageQueueAppendFailedException(“BlockingMessageTransferQueue
transfer timed out”) if the message cannot be added to the mailbox
within the time specified by the pushTimeout.

我在哪里可以捕获此异常?

该文档听起来像我需要包装每个myActor! try / catch中的消息.是对的吗?我真的很想集中处理它.我的主管可能会拦截它并运行我的处理程序吗?

解决方法

尝试使用cc.spray.json._,因为它建立在akka或twitter的finagle之上.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读