Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Akka/scala超大号PayLoadException如何处理?_Scala_Playframework_Playframework 2.0_Akka Http_Akka Cluster - Fatal编程技术网

Akka/scala超大号PayLoadException如何处理?

Akka/scala超大号PayLoadException如何处理?,scala,playframework,playframework-2.0,akka-http,akka-cluster,Scala,Playframework,Playframework 2.0,Akka Http,Akka Cluster,我们在akka集群上有一个分布式应用程序。参与者“A”向远程参与者发送大消息。我们得到以下警告: 2016-08-10 23:08:29737[EndpointWriter]错误-暂时关联 错误(关联仍然有效) akka.remote.OversedPayLoadException:丢弃过大的有效负载 发送给演员[阿卡]。tcp://abcd@127.0.0.1:51665/温度/$b]:允许的最大值 大小128000字节,编码类的实际大小 common.data.model.configura

我们在akka集群上有一个分布式应用程序。参与者“A”向远程参与者发送大消息。我们得到以下警告:

2016-08-10 23:08:29737[EndpointWriter]错误-暂时关联 错误(关联仍然有效) akka.remote.OversedPayLoadException:丢弃过大的有效负载 发送给演员[阿卡]。tcp://abcd@127.0.0.1:51665/温度/$b]:允许的最大值 大小128000字节,编码类的实际大小 common.data.model.configuration.UserList为571444字节


我们知道,我们可以在未来增加价值。但是我们想检查大小是否超过默认限制,我们想发送不同的消息。尝试过搜索,但没有成功大多数人只告诉如何配置它,没有人谈论如何处理它并向远程机器发送消息。任何建议或帮助都将不胜感激。

尝试订阅活动流。希望例外情况就此结束:

import akka.actor.{Actor, Props}
import akka.remote.OversizedPayloadException

class Listener extends Actor {
  def receive = {
    case d: OversizedPayloadException  => {
        // DO SOMETHING
    }
  }
}
val listener = system.actorOf(Props(classOf[Listener], this))
system.eventStream.subscribe(listener, classOf[OversizedPayloadException])

更多信息

向Akka邮件组发布了相同的查询。他们说,好像没有办法处理这个“超大支付例外”。您建议我们在返回actor之前检查数据大小并处理它。

实际上,我们能够处理它,只需要订阅
akka.event.Logging.Error
,然后检查原因是否是
OversedPayLoadException

import akka.actor.{Actor, Props}

class Listener extends Actor {
  override def receive: Receive = {
    case akka.event.Logging.Error(cause, _, _, _)
      // this internal Akka class is package-private, hence we have to check it's classname :(
      if cause.getClass.getName == "akka.remote.OversizedPayloadException" =>
      // handle it here!
  }
}

val listener = system.actorOf(Props(new Listener))
system.eventStream.subscribe(listener, classOf[akka.event.Logging.Error])

当我尝试执行上述操作时,我得到错误“无法在包akka.remote中访问包remote中的class OversedPayLoadException”。我确信我犯了一些基本的错误。你能告诉我为什么我会得到这个异常吗?@Prakash你不能访问它,因为
superbesizedpayloadexception
在akka.remote包中是私有的。p、 我知道,对你来说可能太晚了,但对其他人来说可能不会……)@是的,没错。我现在知道了。请参考下面的答案。我正在尝试检查作为clustermessage的一部分发送的json大小,但在一个边界情况下,如果我的消息大小非常接近限制集(但仍然更小),它会抛出一个错误,表示它正在进一步编码消息,并由于某些编码而增加其大小。你能帮我如何得到正在发送的编码信息的大小吗?太好了。。。我会尽量利用它。非常感谢。