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

Reading and updating agents


Agents are used to provide shared access to storage locations. They provide independent, asynchronous change of individual locations. Agents are bound to a single storage location for their lifetime and only allow mutation of that location (to a new state) to occur as a result of an action. Actions are functions (with, optionally, additional arguments) that are asynchronously applied to an agent's state and whose return value becomes the Agent's new state.

While updates to Agents are asynchronous, the state of an Agent is always immediately available for reading by any thread using get or apply without any messages.

Getting ready

Before we go through this recipe, we will need to download the akka-agent dependency in our project. For this, we will need to add the following dependency to the project's build.sbt:

libraryDependencies += "com.typesafe.akka" % "akka-agent_2.11" % "2.4.4" 

Now, open the terminal in Linux or command prompt in Windows and go to the project...

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 $15.99/month. Cancel anytime
Visually different images