没有合适的资源?快使用搜索试试~ 我知道了~
首页Akka Scala 学习高清原版pdf
资源详情
资源评论
资源推荐
Akka Scala Documentation
Release 2.3.4
Typesafe Inc
June 30, 2014
CONTENTS
1 Introduction 1
1.1 What is Akka? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Why Akka? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 The Obligatory Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 Use-case and Deployment Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.6 Examples of use-cases for Akka . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 General 9
2.1 Terminology, Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Actor Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 What is an Actor? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.4 Supervision and Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.5 Actor References, Paths and Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.6 Location Transparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.7 Akka and the Java Memory Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.8 Message Delivery Reliability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.9 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3 Actors 69
3.1 Actors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.2 Typed Actors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.3 Fault Tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
3.4 Dispatchers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.5 Mailboxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.6 Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
3.7 FSM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
3.8 Persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
3.9 Testing Actor Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
3.10 Actor DSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
4 Futures and Agents 167
4.1 Futures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
4.2 Agents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
5 Networking 177
5.1 Cluster Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
5.2 Cluster Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
5.3 Remoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
5.4 Serialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
5.5 I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
5.6 Using TCP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
5.7 Using UDP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
5.8 ZeroMQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
i
5.9 Camel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
6 Utilities 245
6.1 Event Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
6.2 Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
6.3 Scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
6.4 Duration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
6.5 Circuit Breaker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
6.6 Akka Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
6.7 Microkernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
7 HowTo: Common Patterns 269
7.1 Throttling Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
7.2 Balancing Workload Across Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
7.3 Work Pulling Pattern to throttle and distribute work, and prevent mailbox overflow . . . . . . . . 269
7.4 Ordered Termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
7.5 Akka AMQP Proxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
7.6 Shutdown Patterns in Akka 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
7.7 Distributed (in-memory) graph processing with Akka . . . . . . . . . . . . . . . . . . . . . . . . 270
7.8 Case Study: An Auto-Updating Cache Using Actors . . . . . . . . . . . . . . . . . . . . . . . . 270
7.9 Discovering message flows in actor systems with the Spider Pattern . . . . . . . . . . . . . . . . 271
7.10 Scheduling Periodic Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
7.11 Template Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
8 Experimental Modules 273
8.1 Persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
8.2 Multi Node Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
8.3 Actors (Java with Lambda Support) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
8.4 FSM (Java with Lambda Support) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
8.5 External Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
9 Information for Akka Developers 349
9.1 Building Akka . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
9.2 Multi JVM Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
9.3 I/O Layer Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
9.4 Developer Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
9.5 Documentation Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
9.6 Team . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
10 Project Information 361
10.1 Migration Guides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
10.2 Issue Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
10.3 Licenses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
10.4 Sponsors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
10.5 Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
11 Additional Information 375
11.1 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
11.2 Books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
11.3 Other Language Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
11.4 Akka in OSGi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
11.5 Incomplete List of HTTP Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
ii
CHAPTER
ONE
INTRODUCTION
1.1 What is Akka?
Scalable real-time transaction processing
We believe that writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time it’s
because we are using the wrong tools and the wrong level of abstraction. Akka is here to change that. Using the
Actor Model we raise the abstraction level and provide a better platform to build scalable, resilient and responsive
applications—see the Reactive Manifesto for more details. For fault-tolerance we adopt the “let it crash” model
which the telecom industry has used with great success to build applications that self-heal and systems that never
stop. Actors also provide the abstraction for transparent distribution and the basis for truly scalable and fault-
tolerant applications.
Akka is Open Source and available under the Apache 2 License.
Download from http://akka.io/downloads.
Please note that all code samples compile, so if you want direct access to the sources, have a look over at the Akka
Docs subproject on github: for Java and Scala.
1.1.1 Akka implements a unique hybrid
Actors
Actors give you:
• Simple and high-level abstractions for concurrency and parallelism.
• Asynchronous, non-blocking and highly performant event-driven programming model.
• Very lightweight event-driven processes (several million actors per GB of heap memory).
See the chapter for Scala or Java.
Fault Tolerance
• Supervisor hierarchies with “let-it-crash” semantics.
• Supervisor hierarchies can span over multiple JVMs to provide truly fault-tolerant systems.
• Excellent for writing highly fault-tolerant systems that self-heal and never stop.
See Fault Tolerance (Scala) and Fault Tolerance (Java).
1
Akka Scala Documentation, Release 2.3.4
Location Transparency
Everything in Akka is designed to work in a distributed environment: all interactions of actors use pure message
passing and everything is asynchronous.
For an overview of the cluster support see the Java and Scala documentation chapters.
Persistence
Messages received by an actor can optionally be persisted and replayed when the actor is started or restarted. This
allows actors to recover their state, even after JVM crashes or when being migrated to another node.
You can find more details in the respective chapter for Java or Scala.
1.1.2 Scala and Java APIs
Akka has both a Scala Documentation and a java-api.
1.1.3 Akka can be used in two different ways
• As a library: used by a web app, to be put into WEB-INF/lib or as a regular JAR on your classpath.
• As a microkernel: stand-alone kernel to drop your application into.
See the Use-case and Deployment Scenarios for details.
1.1.4 Commercial Support
Akka is available from Typesafe Inc. under a commercial license which includes development or production
support, read more here.
1.2 Why Akka?
1.2.1 What features can the Akka platform offer, over the competition?
Akka provides scalable real-time transaction processing.
Akka is an unified runtime and programming model for:
• Scale up (Concurrency)
• Scale out (Remoting)
• Fault tolerance
One thing to learn and admin, with high cohesion and coherent semantics.
Akka is a very scalable piece of software, not only in the context of performance but also in the size of applications
it is useful for. The core of Akka, akka-actor, is very small and easily dropped into an existing project where you
need asynchronicity and lockless concurrency without hassle.
You can choose to include only the parts of akka you need in your application and then there’s the whole package,
the Akka Microkernel, which is a standalone container to deploy your Akka application in. With CPUs growing
more and more cores every cycle, Akka is the alternative that provides outstanding performance even if you’re
only running it on one machine. Akka also supplies a wide array of concurrency-paradigms, allowing users to
choose the right tool for the job.
1.2. Why Akka? 2
剩余381页未读,继续阅读
笨小孩Andy
- 粉丝: 1
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 2022年中国足球球迷营销价值报告.pdf
- 房地产培训 -营销总每天在干嘛.pptx
- 黄色简约实用介绍_汇报PPT模板.pptx
- 嵌入式系统原理及应用:第三章 ARM编程简介_3.pdf
- 多媒体应用系统.pptx
- 黄灰配色简约设计精美大气商务汇报PPT模板.pptx
- 用matlab绘制差分方程Z变换-反变换-zplane-residuez-tf2zp-zp2tf-tf2sos-sos2tf-幅相频谱等等.docx
- 网络营销策略-网络营销团队的建立.docx
- 电子商务示范企业申请报告.doc
- 淡雅灰低面风背景完整框架创业商业计划书PPT模板.pptx
- 计算模型与算法技术:10-Iterative Improvement.ppt
- 计算模型与算法技术:9-Greedy Technique.ppt
- 计算模型与算法技术:6-Transform-and-Conquer.ppt
- 云服务安全风险分析研究.pdf
- 软件工程笔记(完整版).doc
- 电子商务网项目实例规划书.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0