Mastering Akka
eBook - ePub

Mastering Akka

Christian Baxter

Share book
  1. 436 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Mastering Akka

Christian Baxter

Book details
Book preview
Table of contents
Citations

About This Book

Master the art of creating scalable, concurrent, and reactive applications using Akka

About This Book

  • This book will help you cure anemic models with domain-driven design
  • We cover major Akka programming concepts such as concurrency, scalability, and reactivity
  • You will learn concepts like Event Sourcing and CQRS via Akka Persistence, Akka Streams, Akka Http as well as Akka Clustering

Who This Book Is For

If you want to use the Lightbend platform to create highly performant reactive applications, then this book is for you. If you are a Scala developer looking for techniques to use all features of the new Akka release and want to incorporate these solutions in your current or new projects, then this book is for you. Expert Java developers who want to build scalable, concurrent, and reactive application will find this book helpful.

What You Will Learn

  • Use Akka actors to enable parallel execution
  • Build out domain-driven design based components like entities and aggregates
  • Respond to command requests on that aggregate root that affect the internal state
  • Leverage Akka Persistence, protobuf and Cassandra to save the persistent state of you entities
  • Build out complex processing graphs with the Graph Builder DSL
  • Understand the dynamic push/pull nature of backpressure handling within Akka Streams
  • Route HTTP requests to an actor and return a response
  • Deploy actor instances across a set of nodes via ConductR for high availability

In Detail

For a programmer, writing multi-threaded applications is critical as it is important to break large tasks into smaller ones and run them simultaneously. Akka is a distributed computing toolkit that uses the abstraction of the Actor model, enabling developers to build correct, concurrent, and distributed applications using Java and Scala with ease.

The book begins with a quick introduction that simplifies concurrent programming with actors. We then proceed to master all aspects of domain-driven design. We'll teach you how to scale out with Akka Remoting/Clustering. Finally, we introduce Conductr as a means to deploy to and manage microservices across a cluster.

Style and approach

This comprehensive, fast-paced guide is packed with several real-world use cases that will help you understand concepts, issues, and resolutions while using Akka to create highly performant, scalable, and concurrency-proof reactive applications.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on ā€œCancel Subscriptionā€ - itā€™s as simple as that. After you cancel, your membership will stay active for the remainder of the time youā€™ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlegoā€™s features. The only differences are the price and subscription period: With the annual plan youā€™ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weā€™ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Mastering Akka an online PDF/ePUB?
Yes, you can access Mastering Akka by Christian Baxter in PDF and/or ePUB format, as well as other popular books in Informatik & Programmieralgorithmus. We have over one million books available in our catalogue for you to explore.

Information

Year
2016
ISBN
9781786465023

Mastering Akka


Mastering Akka

Copyright Ā© 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2016
Production reference: 1141016
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78646-502-3
www.packtpub.com

Credits

Author
Christian Baxter
Copy Editor
Zainab Bootwala
Reviewer
Dennis Vriend
Project Coordinator
Suzanne Coutinho
Commissioning Editor
Kunal Parikh
Proofreader
Safis Editing
Acquisition Editor
Dharmesh Parmar
Indexer
Tejal Daruwale Soni
Content Development Editor
Anish Sukumaran
Graphics
Jason Monteiro
Technical Editor
Sunith Shetty
Production Coordinator
Melwyn Dsa

About the Author

Christian Baxter, from an early age, has always had an interest in understanding how things worked. Growing up, he loved challenges and liked to tinker with and fix things. This inquisitive nature was the driving force that eventually led him into computer programming. While his primary focus in college was life sciences, he always set aside time to study computers and to explore all aspects of computer programming. When he graduated from college during the height of the Internet boom, he taught himself the necessary skills to get a job as a programmer. Heā€™s been happily programming ever since, working across diverse industries such as insurance, travel, recruiting, and advertising. He loves building out high-performance distributed systems using Scala on the Akka platform.
Christian was a long time Java programmer before making the switch over to Scala in 2010. He was looking for new technologies to build out high throughput and asynchronous systems and loved what he saw from Scala and Akka. Since then, he's been a major advocate for Akka, getting multiple ad tech companies heā€™s worked for to adopt it as a means of building out reactive applications. He's also been an occasional contributor to the Akka codebase, identifying and helping to fix issues. When heā€™s not hacking away on Scala and Akka, you can usually find him answering questions on Stackoverflow as cmbaxter.

Acknowledgments

A lot went into the writing of this book, and not just from me. As such, Iā€™d like to thank a few people, starting with the two special women in my life.
To my beautiful wife, Laurie. Thank you for being so patient throughout the writing of this book, and with me, in general. All this time, youā€™ve somehow been able to put up with all my quirks, which is a feat in and of itself. Youā€™ve always believed in me, even if, at times, I didnā€™t believe in myself. Thank you for always challenging me and never letting me be complacent. Without you, this book would have never been possible.
To my amazing mother, you taught me how to be a good person by instilling in me the values one needs to be successful in life. Your strength of character and resilience to lifeā€™s challenges have served as inspirations to me. Youā€™ve always been there for me, no matter how hard the times got. For this, I am eternally grateful.
Lastly, Iā€™d like to thank my very first mentor, Dan Gallagher. I learned so much from you during our time together. Who knows how my career would have ended up if you werenā€™t there in the beginning to screw my head on straight. I appreciate the enormous amount of patience that must have gone into dealing with me way back then. Thank you so much for starting my career down the right path to where I am today.

About the Reviewer

Dennis Vriend is a professional with more than 10 years of experience in programming for the Java Virtual Machine. Over the last 4 years, Dennis has been developing and designing fault tolerant, scalable, distributed, and highly performant systems using Scala, Akka, and Spark, and maintaining them across multiple servers. Dennis is active in the open source community and maintains two very successful Akka pluginsā€”the akka-persistence-jdbc plugin and the akka-persistence-inmemory pluginā€”both useful to design and test state of the art business components leveraging domain-driven design and event sourcing in a distributed environment. Dennis is currently working as a software development engineer for Trivento in the Netherlands.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
www.PacktPub.com
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

  • Fully searchable across every book published by Packt
  • Copy and paste, print, and bookmark content
  • On demand and accessible via a web browser

Preface

The Akka library is well known in the Scala world for providing a means to build reactive applications. Akkaā€™s core building block is the Actor, which is a simple concurrency unit that allows you to build asynchronous, event driven, fault tolerant, and potentially distributed components on top of. Actors are an excellent starting point to build your reactive applications and services on top of, but thereā€™s a lot more within the entire Akka platform that you should be considering as well.
This book will provide the reader with a purpose-built tour through some of the additional modules within the Akka platform. The tour will be conducted by progressively refactoring an initial Akka application from an inflexible monolith all the way to a set of loosely coupled microservices. Along the way, you will learn how to apply new features, such as event sourcing via Akka Persistence, to the application in an effort to help it scale better. When the journey is complete, you will have a much better understanding of these additional offerings within the Akka platform and how they can help you build your applications and services.
Throughout the refactoring process, new concepts and libraries within Akka will be introduced to the reader on a chapter by chapter basis. Within those chapters, I will detail what each new feature is, and how that feature fits into breaking down a monolith into a set of loosely coupled services. Each chapter will also involve coding homework for the reader, giving them an active role in the progressive refactoring process. This hands-on experience will give the reader an immersive understanding of how to use these newer Akka features in the real-world code, which is the main goal of this book.

What this book covers

Chapter 1, Building a Better Reactive App, introduces you to the initial sample application and how it will be improved over the course of this book.
Chapter 2, Simplifying Concurrent Programming with Actors, is a refresher on Actors with some refactoring work using Akkaā€™s FSM.
Chapter 3, Curing Anemic Models with Domain-Driven Design, introduces you to domain-driven design (DDD) and how it helps in modeling and building software.
Chapter 4, Making History with Event Sourcing, presents Akka Persistence as a means to build event-sourced entities.
Chapter 5, Separating Concerns with CQRS, teaches you how to separate read and write models using the CQRS pattern.
Chapter 6, Going with the Flow with Akka Streams, explains how Akka Streams can be used to build back-pressure aware, stream-based processing components.
Chapter 7, REST Easy with Akka HTTP, shows you how to leverage Akka HTTP to build and consume RESTful interfaces.
Chapter 8, Scaling Out with Akka Remoting/Clustering, demonstrates how to use remoting and clustering to gain horizontal scalability and high availability.
Chapter 9, Managing Deployments with ConductR, illustrates building, deploying, and locating your microservices with ConductR.
Chapter 10, Troubleshooting and Best Practices, presents a few final tips and best practices for using Akka.

What you need for this book

You will need a computer (Windows or Mac OS X) with Java 8 installed on it. You will need to have Simple Build Tool (sbt) installed on that computer as well. This book also leverages Docker, with the installation of Docker being covered in more detail in Chapter 1, Building a Better Reactive App.

Who this book is for

If you want to use the Lightbend platform to create highly-performant reactive applications, then this book is for you. If you are a Scala developer looking for techniques to use all features of the new Akka release and want to incorporate these solutions in your current or new projects, then this book is for you. Expert Java developers who want to build scalable, concurrent, and reactive application will find this book helpful.

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: "If you want to stop a Docker container, use the docker stop command, supplying the name of the container you want to stop."
A block of code is set as follows:
{ "firstName": "Chris", "lastName": "Baxter", "email": "[email protected]" }
Any command-line input or output is written as follows:
 docker-build.sh 
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in th...

Table of contents