申请试用
HOT
登录
注册
 
Akka的高级主题介绍
献良
/
发布于
/
2963
人观看
用最精炼的语言(图)来描绘出Akka编程的基本核心组件的概念,并点出基本原理,特别是编程方法,是akka概念性入门的非常好的参考资料。
展开查看详情

1 .A Tour of (Advanced) Akka Features in 40 Minutes Johan Janssen, Info Support @johanjanssen42

2 .Content ▪ Why Akka? ▪ Sharding ▪ Local actor ▪ Persistence ▪ Remote actor ▪ Akka HTTP ▪ Scheduling ▪ Finite State Machines ▪ Cluster ▪ Conclusion ▪ Routing ▪ Questions ▪ Cluster singleton

3 .Why Akka?

4 .Why Akka? ▪ Concurrent ▪ Scalable ▪ Fault tolerant ▪ More natural programming experience when connecting to other systems ▪ Easy to use?

5 .

6 .Local actor

7 .Local actor Actor on JVM 1

8 . Local actor Coordinator Actor Hello conference

9 .Local actor Coordinator Actor println("Hello conference")

10 .class Worker extends Actor { Scala def receive = { case x => println(x) } } val system = ActorSystem("ExampleActorSystem") val workerActorRef = system.actorOf(Props[Worker]) workerActorRef ! "Hello conference"

11 .Remote actor

12 .Remote actor Actor on Actor on JVM 1 JVM 2

13 .val workerActorRef = system.actorOf(Props[Worker]) workerActorRef ! "Hello conference" val workerActorRef = context.actorSelection("akka.tcp:// ExampleActorSystem@127.0.0.1:9005 /user/workerActor") workerActorRef ! "Hello conference"

14 .akka { actor { provider = "akka.remote.RemoteActorRefProvider" } remote { enabled-transports = ["akka.remote.netty.tcp"] netty.tcp { hostname = "127.0.0.1" port = 9002

15 . Remote actor StartMessage Hello conference Coordinator Worker actor actor

16 . Remote actor WorkerMessage Greetings from the coordinator: Coordinator Hello Conference Worker actor actor

17 . Remote actor WorkerResponse Message Item processed Coordinator successfully Worker actor actor

18 .Scheduling

19 . Scheduling Tick Scheduled once after 1 second system.scheduler.scheduleOnce(1 seconds, scheduleReceiveActor, Tick) Actor Tock Scheduled every 5 seconds system.scheduler.schedule(0 seconds, 5 seconds, scheduleReceiveActor, Tock)

20 .Scheduling ▪ Does not work for fixed point in time like 17:00 – Use Quartz

21 .Cluster

22 .Cluster ActorSystem on JVM 2 ActorSystem ActorSystem on JVM 1 on JVM 3 ActorSystem on JVM 4

23 .Seed nodes ▪ Contact points for automatically joining a cluster

24 .akka { cluster { seed-nodes = [ "akka.tcp://ClusterNode@127.0.0.1:2551", "akka.tcp://ClusterNode@127.0.0.1:2552" ] } }

25 .Cluster Worker Node Port 2551 Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2552

26 .Cluster Worker Node Member Up with IP: 127.0.0.1 and port: 2551 Member Up with IP: 127.0.0.1 and port: 2552 Port 2551 Worker Node Member Up with IP: 127.0.0.1 and port: 2551 Member Up with IP: 127.0.0.1 and port: 2552 Port 2552

27 . Cluster Worker Node Member Up with IP: 127.0.0.1 and port: 2550 Port 2551 Coordinator Worker Node Node Port 2550 Member Up with IP: 127.0.0.1 and port: 2550 Port 2552

28 .Cluster Worker RegisterWorker Node Port 2551 Coordinator Worker Node RegisterWorker Node Port 2550 Port 2552

29 . Cluster Worker Node Port 2551 Coordinator Worker Node Node Port 2550 Port 2552 Worker registered with IP: 127.0.0.1 and port: 2551 Worker registered with IP: 127.0.0.1 and port: 2552

3 点赞
2 收藏
1下载
确认
3秒后跳转登录页面
去登陆