如题,打算测试一下AKKA的actor模型远程传输的限制,结果还真发现了点问题。
设计测试用例如下:
Client端:
1 package cn.wanda.local 2 3 import akka.actor.Actor 4 import module.{ListType, JsonType, SeqType} 5 6 import java.util.ArrayList 7 /** 8 * Created by Administrator on 2014/11/17. 9 */ 10 class LocalActor extends Actor { 11 12 val remote = context.actorSelection("akka.tcp://[email protected]:8000/user/RemoteActor")// create the remote actor 13 var counter = 0 14 //val seq:IndexedSeq[Int] = for(i <- 0 to 12335) yield i 15 val list = List(1 to 100000:_*) 16 17 def receive = { 18 case "START" => { 22 remote ! new ListType(list) 23 } 24 case msg: String =>{ 25 println(s"LocalActor received message: ‘$msg‘") 26 }27 } 28 }
Server端:
1 package cn.wanda.remote 2 3 import akka.actor.Actor 4 import module.{ListType, SeqType} 5 /** 6 * Created by Administrator on 2014/11/17. 7 */ 8 class RemoteActor extends Actor { 9 def receive = { 10 case msg: String => { 11 println(s"RemoteActor received message ‘$msg‘") 12 println(sender().toString()) 13 //sender ! Future.successful("Hello from the RemoteActor") 14 } 15 case seq: SeqType => { 16 print(seq) 17 } 18 case list: ListType => { 19 //println("hello") 20 println(list) 21 } 22 } 23 }
将这个100000长度的数组发送到远程的Actor
Client端的输出如下:
[DEBUG] [12/03/2014 16:45:32.173] [main] [EventStream(akka://LocalSystem)] logger log1-Logging$DefaultLogger started [DEBUG] [12/03/2014 16:45:32.176] [main] [EventStream(akka://LocalSystem)] Default Loggers started [INFO] [12/03/2014 16:45:32.260] [main] [Remoting] Starting remoting [INFO] [12/03/2014 16:45:32.821] [main] [Remoting] Remoting started; listening on addresses :[akka.tcp://[email protected]:53304] [INFO] [12/03/2014 16:45:32.825] [main] [Remoting] Remoting now listens on addresses: [akka.tcp://[email protected]:53304] ----ActorSelection[Anchor(akka.tcp://[email protected]:8000/), Path(/user/RemoteActor)] [DEBUG] [12/03/2014 16:45:33.204] [LocalSystem-akka.remote.default-remote-dispatcher-6] [akka.tcp://[email protected]:53304/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FHelloRemoteSystem%40localhost%3A8000-0/endpointWriter] Associated [akka.tcp://[email protected]:53304] -> [akka.tcp://[email protected]:8000] [DEBUG] [12/03/2014 16:45:33.211] [LocalSystem-akka.remote.default-remote-dispatcher-6] [akka.serialization.Serialization(akka://LocalSystem)] Using serializer[akka.serialization.JavaSerializer] for message [module.ListType] [ERROR] [12/03/2014 16:45:33.340] [LocalSystem-akka.remote.default-remote-dispatcher-6] [akka.tcp://[email protected]:53304/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FHelloRemoteSystem%40localhost%3A8000-0/endpointWriter] Transient association error (association remains live) akka.remote.OversizedPayloadException: Discarding oversized payload sent to Actor[akka.tcp://[email protected]:8000/]: max allowed size 128000 bytes, actual size of encoded class akka.actor.ActorSelectionMessage was 1000508 bytes. [DEBUG] [12/03/2014 16:45:33.341] [LocalSystem-akka.remote.default-remote-dispatcher-6] [akka.tcp://[email protected]:53304/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FHelloRemoteSystem%40localhost%3A8000-0/endpointWriter] Drained buffer with maxWriteCount: 50, fullBackoffCount: 1, smallBackoffCount: 0, noBackoffCount: 0 , adaptiveBackoff: 1000
Server端输出如下:
[DEBUG] [12/03/2014 16:45:33.191] [HelloRemoteSystem-akka.remote.default-remote-dispatcher-5] [Remoting] Associated [akka.tcp://[email protected]:8000] <- [akka.tcp://[email protected]:53304]
在Client端的输出信息里有这样一句:
[ERROR] [12/03/2014 16:45:33.340] [LocalSystem-akka.remote.default-remote-dispatcher-6] [akka.tcp://[email protected]:53304/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FHelloRemoteSystem%40localhost%3A8000-0/endpointWriter] Transient association error (association remains live)
akka.remote.OversizedPayloadException: Discarding oversized payload sent to Actor[akka.tcp://[email protected]:8000/]: max allowed size 128000 bytes, actual size of encoded class akka.actor.ActorSelectionMessage was 1000508 bytes.
最大允许发送128000bytes大小的消息,也就是125kb,但输出端似乎也接收到了什么,消息到底发送到哪里了,后续再细说.....未完,待续