Using Case Classes to Structure Your Data By Daniela Sfregola This article, taken from the pages of Get Programming with Scala, discusses an important tool in your Scala toolbox, called “case class.” Save 37% off Get Programming with Scala with code fccsfregola at manning.com. When coding, dealing with data is an… Continue reading Using Case Classes to Structure Your Data
Category: 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
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 Integrate ReactiveMongo in your Akka Spray Application
Scalability can be challenging when database access is needed: the common approach is to block the thread until a response is received. ReactiveMongo is a MongoDB Scala Driver that provides fully non-blocking asynchronous I/O operation that increases the scalability of your system. In a previous post we have seen how to build a REST Api… Continue reading How to Integrate ReactiveMongo in your Akka Spray Application
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