Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
payload有没有办法在向 akka 演员发送消息时添加某种(附加消息)?我知道有一种方法可以做到这一点routers,但这可以通过简单的消息传递来实现吗?
payload
routers
通过简单的消息传递,我的意思是这样的remoteActor ! "hi"。
remoteActor ! "hi"
是的,是的,你可以。您可以发送任何您想要的有效负载,但它必须是不可变的(据我所知)。大多数人使用案例类。例如。
case class Payload(pay: List[String], load: Int)
那么您可以执行以下操作
actorRef ! Payload(List("string1","1gnirts"),69)
但是您必须记住在接收中创建适当的案例
def receive = case Payload(pay,load) => doSomeStuff(load,pay)