REST services are quite commonly used in scalable architectures because they are stateless. However, in the practical world, a service is rarely just a CRUD service: for example we could also have some background processing (i.e.: downloading/parsing files, scheduled processed, triggers, etc). In this tutorial we demonstrate how to use an Akka SingletonClusterManager in a… Continue reading Background Processing with Akka Cluster: ClusterSingletonManager
Tag: Tutorial
How to build a REST API with Akka Http
In previous articles we have discussed how to use Spray to build REST APIs. Since Akka 2.4, Spray is no longer supported and it is replaced by Akka Http. This article will introduce Akka Http, the new shiny toy from the Akka Team, and provide a tutorial on how it can be used to create… Continue reading How to build a REST API with Akka Http
How to build a Scala REST CRUD application with Spray
In previous articles we have described how to build a REST Api with Spray and how to (de)serialize case classes with json4s. However, in order to keep things simple, we didn't always do things as suggested by spray.io. In this article we will redeem ourselves and we will describe how to build a REST CRUD… Continue reading How to build a Scala REST CRUD application with Spray
Spray: how to (de)serialize objects with json4s
A while ago I wrote an article on how to build a REST api with Spray, where I used the Spray facilities to serialize and deserialize objects to and from JSON. This article will analyze how we can make the (de)serialization of our case classes easier, by using a library called json4s. All the code… Continue reading Spray: how to (de)serialize objects with json4s
How to Create a Spray Custom Authenticator
Spray has a few standard authenticators already built in. However, what if the authentication we need is not supported? In this article we will describe how to create a custom authenticator in Spray. In particular, we will implement a custom client id/secret token-based authentication. Spray Authentication: how it works Spray has already some built in… Continue reading How to Create a Spray Custom Authenticator
Akka Dead Letters Channel
Akka doesn't guarantee the delivery of a message. What happens when a message cannot be delivered? In this article we will describe how the Dead Letters Channel works and how it can be used to spot issues in our system. How it works In a previous article we have described the use of Event Streams… Continue reading Akka Dead Letters Channel
Peer-to-Many Communication in Akka
The most common communication channel in Akka is Peer-to-Peer, where an individual actor sends a message directly to another individual actor actor. However, sometimes this is not enough as we may need a Peer-to-Many type of communication, where an individual actor sends a message to a group of actors. This is particularly useful when you… Continue reading Peer-to-Many Communication in Akka
How to Compose Futures
Futures are a powerful tool that has been developed by the Akka team and then adopted as a standard Scala library from version 2.10. A Future is a placeholder for a value that will be available in the future: thanks to it, it is possible to run operations in parallel and to worry about what… Continue reading How to Compose Futures
How to Supervise Akka Actors
Supervision is one of the core operations that an Actor can fulfill. Handling errors is not always easy in a classic object oriented programming context as exceptions can be difficult to predict as they are fully embedded in the normal execution flow. In the Akka Actor Model, errors are handled in a well-structured isolated execution… Continue reading How to Supervise Akka Actors
How to test Actors with Akka TestKit and Spec2
Actors are a really powerful tool to handle concurrency thanks to their message-based model. However, they can be tricky to test: sending and processing messages is done asynchronously. Moreover, their status is hidden internally and it cannot be easily accessed to make assertions on it. The Akka Team has created a library, called akka-testkit, to… Continue reading How to test Actors with Akka TestKit and Spec2