flink_book/source_code/Flink组件通信.md

20 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Flink组件通信原理
![Flink组件通信原理](https://pan.zeekling.cn/flink/akka/akka_actor.png)
## Akka总结
- ActorSystem 是管理 Actor生命周期的组件Actor是负责进行通信的组
- 每个 Actor 都有一个 MailBox别的 Actor 发送给它的消息都首先储存在 MailBox 中,通过这种方式可以实现异步通信。
- 每个Actor 是单线程的处理方式,不断的从 Mai1Box 拉取消息执行处理所以对于Actor的消息处理不适合调用会阻塞的处理方法。
- Actor 可以改变他自身的状态,可以接收消息,也可以发送消息,还可以生成新的 Actor
- 每一个ActorSystem 和Actor都在启动的时候会给定一个 name如果要从ActorSystem中获取一个 Actor
则通过以下的方式来进行 Actor的获取`akka.tcp://asnamebigdata02:9527/user/actorname`
- 如果一个 Actor 要和另外一个 Actor进行通信则必须先获取对方 Actor的 ActorRef 对象,然后通过该对象发送消息即可。
- 通过 te11 发送异步消息,不接收响应,通过 ask 发送异步消息,得到 Future 返回,通过异步回到返回处理结果。