Akka 简介与入门

Akka 简介与入门

http://www.thinksaas.cn/group/topic/344095/

参考官网  http://akka.io/

开源代码  https://github.com/akka/akka

Slogan:

Build powerful concurrent &distributed applications more easily.

轻松构建健壮的并发和分布式应用

Akka是什么?

Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM.

Akka是一个在JVM上构建高并发、分布式和可快速恢复的消息驱动应用的工具集和运行时。

Akka特性

Simple Concurrency &Distribution 简单的并发和分布式

Asynchronous and Distributed by design. High-level abstractions like Actors, Futures and STM.

Resilient by Design  快速恢复设计

Write systems that self-heal. Remote and/or local supervisor hierarchies.

High Performance  高性能

50 million msg/sec on a single machine. Small memory footprint;~2.5 million actors per GB of heap.

Elastic &Decentralized 弹性和去中心化

Adaptive load balancing, routing, partitioning and configuration-driven remoting.

Extensible  可扩展

Use Akka Extensions to adapt Akka to fit your needs.

重要概念/术语

Actors

Actors are very lightweight concurrent entities. They process messages asynchronously using an event-driven receive loop. Pattern matching against messages is a convenient way to express an actor's behavior. They raise the abstraction level and make it much easier to write, test, understand and maintain concurrent and/or distributed systems. You focus on workflow—how the messages flow in the system—instead of low level primitives like threads, locks and socket IO.

Remoting

Actors are location transparent and distributable by design. This means that you can write your application without hardcoding how it will be deployed and distributed, and then later just configure your actor system against a certain topology with all of the application’s semantics, including actor supervision, retained.

Supervision

Actors form a tree with actors being parents to the actors they've created. As a parent, the actor is responsible for handling its children’s failures (so-called supervision), forming a chain of responsibility, all the way to the top. When an actor crashes, its parent can either restart or stop it, or escalate the failure up the hierarchy of actors. This enables a clean set of semantics for managing failures in a concurrent, distributed system and allows for writing highly fault-tolerant systems that self-heal.

中文资料

基于AKKA的后台应用开发手册

http://wenku.baidu.com/link?url=aixo8_UPSQLw21ptfsrGfrNSy9T6okD9VsFTYqposHnupsmwTAvOCFjSyBOhfhX9DRn-4chxcK_hWc6gIMIiup8fiMERm4Iw-TCSDQSYLNy

Akka分片集群的实现

http://wenku.baidu.com/link?url=R9B9R6VJ_oVhZcyCByEdlJSkHprMLhB77L181ax7VpoRRfdFofzZ3wPc41QA_pY99d6WVU9ZuONu6K_kS58Mj4JzJZcDXMye8m7NjVpIjyG

使用Akka的Actor和Future简单地实现并发处理

http://www.th7.cn/Program/java/2012/03/29/67015.shtml

Java中使用akka手记一

http://2014.54chen.com/blog/2014/04/14/how-to-use-akka-in-java/

示例代码

public class Greeting implements Serializable {public final String who;public Greeting(String who) {this.who=who;}}public class GreetingActor extends UntypedActor {LoggingAdapter log=Logging.getLogger(getContext().system(), this);public void onReceive(Object message) throws Exception {if (message instanceof Greeting) log.info("Hello " + ((Greeting) message).who);}}ActorSystem system=ActorSystem.create("MySystem");ActorRef greeter=system.actorOf(Props.create(GreetingActor.class), "greeter");greeter.tell(new Greeting("Charlie Parker"), ActorRef.noSender());
上一篇:BayaiM__Linux安装MySQL的两种方法


下一篇:Linux下安装Tomcat服务器