Book Image

Mastering Akka

By : Christian Baxter
Book Image

Mastering Akka

By: Christian Baxter

Overview of this book

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.
Table of Contents (17 chapters)
Mastering Akka
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface

Troubleshooting and best practices for Akka HTTP


When using Akka HTTP, there are a few best practices and a troubleshooting tip that I'd like to share with you. With the information in this section, you will be better equipped to employ Akka HTTP within your codebase.

Trouble with the tilde

Back in Chapter 7, REST Easy with Akka HTTP, when discussing the high-level Inbound HTTP API, we talked about composing routes together with the tile operator (~). At the end of the section titled Composing directives together, I gave a tip about forgetting to include the ~ and the effect it can have. Here, I'll provide a more concrete example of this problem and the symptom you will see when you encounter it. Consider the following set of routes that you set up to handle your inbound requests:

pathPrefix("book"){ 
  (get & path(Segment)){ id => 
    . . . 
  } 
  (post & entity(as[CatalogNewBook])){ req => 
    . . . 
  } 
} 

The intention here was to...