对于akka中,actor模型的理解。
来源:互联网 发布:巅峰seo 编辑:程序博客网 时间:2024/05/16 06:19
1.创建ActorSystem.
ActorSystem actorSystem = ActorSystem.create();
2.创建Actor的引用 这里创建 a b两个引用
ActorRef a = actorSystem.actorOf(Props.create(A.class));
ActorRef b =actorSystem.actorOf(Props.create(B.class));
3.通过引用.tell()发送消息.
eg:a.tell("hello", b); 发送消息给A Actor,发送方为b引用.
4.tell方法实际是将消息发送到A这个Actor 的mailbox, 当接收方Actor读取mailbox里的消息时,mailbox就会调用接收方Actor 里的onReceive方法(在这个方法里接收信息,做处理)。
- public class A extends UntypedActor {
- public void onReceive(Object message) throws Exception {
- System.out.println("A receive message : " + message);
- getSender().tell("hello! I am A!", getSelf());
- }
- }
阅读全文
0 0
- 对于akka中,actor模型的理解。
- akka---actor模型
- 【Akka】Actor模型探索
- Akka之actor模型
- akka actor理解
- 【Akka】Akka中actor的生命周期与DeathWatch监控
- [akka] Actor的生命周期
- .NET的Actor模型:Orleans Orleans是微软推出的类似Scala Akka的Actor模型,
- akka基础 : 理解Actor 系统
- scala之Akka的Actor模型(下)
- scala之Akka的Actor模型(上)
- Akka Actor 模型云计算架构以及 Remote Actor的简单示例
- scala中akka actor例子
- akka actor中FSM有限状态机的设计原则
- 关于 Akka actor中使用 slf4j日志的问题
- AKKA-源码-Actor的结构设计
- Actor编程模型——akka
- Actor模型和Akka消息驱动系统
- Java遍历一个类的所有属性和值
- WEB优化
- Elastic 5.3 Native Script实现
- PhoneGap安装和使用教程
- 在C#中STRING与DOUBLE的转换方法
- 对于akka中,actor模型的理解。
- android Character.isWhitespace 判断是否是空白char及提供判断空白字符串
- PAT乙级1011. A + B和C(15)
- opencv 15 OCR 文本检测(textdetection) vs2015
- 高级C语言教程-指针和存储
- 【2017十月欢乐赛Day2】subset
- 接口
- js验证整数
- vuejs中vue-resource或使用axios发送请求及解决跨域问题