是否可以通過TCP/IP將消息發送給AKKA actor?發送TCP/IP消息AKKA actor
例如,寫這樣一個客戶端:
mySocket = new Socket("theactor", 75);
os = new DataOutputStream(smtpSocket.getOutputStream());
os.writeBytes("HELLO");
這可能將消息發送到AKKA演員?
謝謝
是否可以通過TCP/IP將消息發送給AKKA actor?發送TCP/IP消息AKKA actor
例如,寫這樣一個客戶端:
mySocket = new Socket("theactor", 75);
os = new DataOutputStream(smtpSocket.getOutputStream());
os.writeBytes("HELLO");
這可能將消息發送到AKKA演員?
謝謝
是的,沒有。你將不得不使用阿卡IO模塊或阿卡駱駝模塊(與網狀或米娜分量):
上維克托的迴應闡述多一點,最小的例子是
import akka.actor._
import ActorDSL._
import java.net.InetSocketAddress
object Server extends App {
implicit val sys = ActorSystem("telnet")
actor(new Act with ActorLogging {
IOManager(context.system) listen new InetSocketAddress(1234)
become {
case IO.NewClient(server) ⇒
server.accept()
case IO.Read(handle, bytes) ⇒
log.info("got {} from {}", bytes.decodeString("utf-8"), handle)
}
})
}
然後在不同的shell開始telnet localhost 1234
並開始鍵入,您會看到每行有一個actor日誌消息。
如果您試圖通過使用IP的遠程演員發送消息,爲什麼不嘗試Akka Remote Actor系統? "Read it here"