Book description
Learn how to use the Akka framework to build effective applications in Scala
About This Book
- Covers a discussion on Lagom—the newest launched Akka framework that is built to create complex microservices easily
- The recipe approach of the book allows the reader to know important and independent concepts of Scala and Akka in a seamless manner
- Provides a comprehensive understanding of the Akka actor model and implementing it to create reactive web applications
Who This Book Is For
If you are a Scala developer who wants to build scalable and concurrent applications, then this book is for you. Basic knowledge of Akka will help you take advantage of this book.
What You Will Learn
- Control an actor using the ContolAware mailbox
- Test a fault-tolerant application using the Akka test kit
- Create a parallel application using futures and agents
- Package and deploy Akka application inside Docker
- Deploy remote actors programmatically on different nodes
- Integrate Streams with Akka actors
- Install Lagom and create a Lagom project
In Detail
Akka is an open source toolkit that simplifies the construction of distributed and concurrent applications on the JVM. This book will teach you how to develop reactive applications in Scala using the Akka framework.
This book will show you how to build concurrent, scalable, and reactive applications in Akka. You will see how to create high performance applications, extend applications, build microservices with Lagom, and more.
We will explore Akka's actor model and show you how to incorporate concurrency into your applications. The book puts a special emphasis on performance improvement and how to make an application available for users. We also make a special mention of message routing and construction.
By the end of this book, you will be able to create a high-performing Scala application using the Akka framework.
Style and approach
This highly practical recipe-based approach will allow you to build scalable, robust, and reactive applications using the Akka framework.
Table of contents
- Preface
-
Diving into Akka
- Introduction
- Creating an Akka Scala SBT project from scratch
- Creating and understanding ActorSystem
- Defining the actor's behavior and state
- Sending messages to actors
- Asking for a result from an actor
- Communication between actors
- Creating a custom mailbox for an actor
- Prioritizing messages that an actor receives
- Creating a control-aware mailbox for an actor
- Become/unbecome behavior of an actor
- Stopping an actor
- Supervision and Monitoring
-
Routing Messages
- Introduction
- Creating a SmallestMailboxPool of actors
- Creating a BalancingPool of actors
- Creating a RoundRobinPool of actors
- Creating a BroadcastPool of actors
- Creating a ScatterGatherFirstCompletedPool of actors
- Creating a TailChoppingPool of actors.
- Creating a ConsistentHashingPool of actors
- Creating a RandomPool of actors
- Sending specially handled messages to routers
- Creating a dynamically resizable pool of actors
-
Using Futures and Agents
- Introduction
- Using a future directly for a simple operation
- Using futures with actors
- Using futures inside actors
- Using for-comprehensions for futures
- Handling callback on futures
- Creating a simple parallel application using futures
- Reducing a sequence of futures
- Reading and updating agents
- Composing agents monadically
-
Scheduling Actors and Other Utilities
- Introduction
- Scheduling an operation at a specified interval
- Scheduling an actor's operation at a specified interval
- Canceling a scheduled operation of the actor
- Creating a circuit breaker to avoid cascading failure
- How to introduce logging with actors
- Writing unit test for actors
- Packaging and deploying the Akka standalone application
- Packaging and deploying Akka application inside a Docker container
- Configurating Akka applications
-
Akka Persistence
- Introduction
- Preparing an actor for persistence
- Recovering the state of an actor
- Safely shutting down a persistent actor
- Reducing recovery time using snapshots
- Creating a persistence FSM model
- Persisting the state to LevelDB
- Persisting the state to Cassandra
- Persisting the state to Redis
- Understanding event sourcing
- Handling failure in event sourcing
- Using persistence query
- Persistence query for LevelDB
-
Remoting and Akka Clustering
- Introduction
- Enabling Akka applications for remoting
- Creating remote actors on different machines
- Looking up remote actors from different machines
- Deploying remote actors programmatically on different nodes
- Scaling out your application using remote actors
- Creating a chat-based application using remote actors
- Enabling Akka clustering for your project
- Using Distributed Publish-Subscribe in the cluster
- Cluster Sharding
- Sharing data between nodes in an Akka cluster
- Creating a singleton actor across clusters
-
Akka Streams
- Introduction
- Creating simple Akka Streams
- How to transform streams and consume them
- Creating stream sources, flows, and sinks
- Custom stream processing
- Error handling in Akka streams
- Pipelining and parallelizing streams
- Working with streaming I/O
- Integrating streams with Akka actors
- Working with graphs
- Processing RabbitMQ messages with Akka streams
- Integrating Akka Streams with Kafka using Reactive Kafka
-
Akka HTTP
- Introduction
- Creating a minimal HTTP server using Akka HTTP
- Consuming Akka HTTP services using a client-side API
- Writing routing DSL for HTTP servers
- Understanding the configuration of Akka HTTP
- Marshaling and unmarshaling data
- Encoding and decoding data
- Understanding directives
- Exception handling
- Uploading a file using Akka HTTP
- Building JSON support with Akka HTTP
- XML support with Akka HTTP
-
Understanding Various Akka patterns
- Introduction
- The Master Slave work pulling pattern
- Ordered termination of actors
- Shutdown patterns in Akka
- Scheduling periodic messages to an actor
- Throttling of messages while sending them to an actor
- Balancing workload across actors
- The aggregator pattern
- The CountDownLatch pattern
- Finite-state machine
- The pausable actor pattern
- Enveloping actor
- Microservices with Lagom
Product information
- Title: Akka Cookbook
- Author(s):
- Release date: May 2017
- Publisher(s): Packt Publishing
- ISBN: 9781785288180
You might also like
book
Effective Akka
Avoid common mistakes when building distributed, asynchronous, high-performance software with the Akka toolkit and runtime. With …
book
Mastering Akka
Master the art of creating scalable, concurrent, and reactive applications using Akka About This Book This …
book
Mastering Play Framework for Scala
Leverage the awesome features of Play Framework to build scalable, resilient, and responsive applications In Detail …
book
Scala Reactive Programming
Build fault-tolerant, robust, and distributed applications in Scala About This Book Understand and use the concepts …