Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Akka Cookbook

You're reading from   Akka Cookbook Recipes for concurrent, fast, and reactive applications

Arrow left icon
Product type Paperback
Published in May 2017
Publisher Packt
ISBN-13 9781785288180
Length 414 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
 Mishra Mishra
Author Profile Icon Mishra
Mishra
Héctor Veiga Ortiz Héctor Veiga Ortiz
Author Profile Icon Héctor Veiga Ortiz
Héctor Veiga Ortiz
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Diving into Akka FREE CHAPTER 2. Supervision and Monitoring 3. Routing Messages 4. Using Futures and Agents 5. Scheduling Actors and Other Utilities 6. Akka Persistence 7. Remoting and Akka Clustering 8. Akka Streams 9. Akka HTTP 10. Understanding Various Akka patterns 11. Microservices with Lagom

Preface

Akka is a popular toolkit that helps develop concurrent, scalable, resilient, and reactive applications in the JVM thanks to the actor model. The toolkit has been around for some years, so we can consider it as a mature technology. Moreover, it has been successfully implemented by many companies, such as Cisco, Amazon.com, and Groupon. This book helps you understand how Akka (and all the modules around it) work and provides a set of useful recipes to easily achieve several of the most common tasks. It also includes an introductory chapter on Lagom, the latest microservices framework by Lightbend, the company behind the development of Akka.

What this book covers

Chapter 1, Diving into Akka, covers the basic concepts of Akka: actors, actor systems, mailboxes, and switching actor behaviors.

Chapter 2, Supervision and Monitoring, covers the actor life cycle, actor hierarchy, supervision, and monitoring.

Chapter 3, Routing Messages, covers the different types of group and pool router and how the Akka dispatcher works.

Chapter 4, Using Futures and Agents, covers how futures work and how well they integrate with the Akka toolkit. It also covers Akka agents.

Chapter 5, Scheduling Actors and Other Utilities, explains how the Akka scheduler works and contains various useful recipes about packaging, configuring, and running your Akka application.

Chapter 6, Akka Persistence, explains how to persist the state of an stateful actor to a variety of technologies, such as Apache Cassandra and Redis. It also covers different recovering strategies.

Chapter 7, Remoting and Akka Clustering, covers how to use Akka beyond a single JVM, either by using a well-known remote address or by joining a decentralized peer-to-peer-based cluster membership service.

Chapter 8, Akka Streams, covers the Akka Streams framework and how to integrate it with Akka and with third-party technologies.

Chapter 9, Akka HTTP, explains how to use Akka HTTP both on the client and server side. Also, it shows how to choose the API level depending on the use case.

Chapter 10, Understanding Various Akka Patterns, covers how to use different common programming patterns using Akka.

Chapter 11, Microservices with Lagom, introduces Lagom, the microservices framework from Lightbend. It provides information about conventions and how to create, configure, connect, and run microservices with Lagom.

What you need for this book

In this book, you will find recipes that provide examples that show the expected behavior. All code examples are written in the programming language Scala (http://www.scala-lang.org/). Akka also provides a Java API, which we will not be covering in the examples. Despite that, the rationale behind all the recipes work the same in either Java or Scala. This book can also be used by Java developers to understand the core concepts of the different recipes.

In addition to Scala, we use sbt (http://www.scala-sbt.org/) as the build tool for the examples in the book. Sbt not only does dependency management, but also helps us run our examples.

Finally, it is recommended (but not required) to use an IDE to develop the different recipes. IntelliJ IDEA or Scala IDE are two good examples of free IDEs to develop Scala applications.

Who this book is for

This book goes through many aspects of the Akka toolkit. From easy recipes, such as Sending messages to Actors, to advanced topics, such as Master Slave work pulling pattern, its aim is to provide useful examples and explanations of how to achieve different patterns with Akka. Even if you are just starting with Akka or you have already used it in the past, these pages will provide you with a deep understanding of Akka that can be applied to new tasks not covered in this book.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

 

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We create a project build definition file called build.sbt by executing a simplesbtcommand."

A block of code is set as follows:

import akka.actor.Props
import akka.actor.ActorSystem
object BehaviourAndState extends App {
  val actorSystem = ActorSystem("HelloAkka")
  // creating an actor inside the actor system
  val actor = actorSystem.actorOf(Props[SummingActor])
  // print actor path
  println(actor.path)
}

Any command-line input or output is written as follows:

sbt "runMain com.packt.chapter1.BehaviorAndState"
akka://HelloAkka/user/$a

New terms and important words are shown in bold.

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors .

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Akka-Cookbook. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

 

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images