How to implement a REST Web Service using Akka?

Kamesh Rao Yeduvakula picture Kamesh Rao Yeduvakula · Jul 12, 2011 · Viewed 22.3k times · Source

I intend to implement a pure Akka powered REST based Web API. I am not sure about using spray. I would consider using Scalatra if it is any good. Basically I am interested in using the concurrency benefits of Scala Actor model. I don't want the Servlet container to be an hindrance in that process.

What can be other options?

Update 1: Which is better frontend for implementing REST based on Akka backend? - Spray, Scalatra or Dropwizard or any other?

Answer

Thomas Lockney picture Thomas Lockney · Jul 12, 2011

The important thing to realize about Akka is that it's not an all-or-nothing environment. You can, to a large degree, mix and match different libraries to compose the system that makes sense for you. For instance, I have written apps that use Dropwizard fronting a backend which uses Akka, without issue. I have also done the same with Clothesline (implemented in Clojure, but with a Scala wrapper). And later this week, I hope to experiment with using Unfiltered's websocket implementation to sit in front of Akka and a RabbitMQ pipe for feeding near real-time data to the client browsers -- I specifically mention this example because the Unfiltered websocket impl sits on top of Netty rather than a servlet container).

Update: Since having written this answer a few years back, I've begun using Spray exclusively for RESTful development with Akka. While pretty much any JVM REST library can be used, Spray fits very naturally into Akka's actor-based model and the library has clearly reached a level of maturity where it can easily be the default choice. The upcoming integration of Spray into Akka as the new akka-http module is a clear indication of this.