Home » Tag Archives: Akka

Tag Archives: Akka

Alternating between Spray-servlet and Spray-can

akka-logo

On a server you may want to deploy your application as a war. How to build a war with spray-servlet. Locally it’s easiest to run without an application server. We include both the spray-servlet and spray-can dependencies: name := "sprayApiExample" version := "1.0" scalaVersion := "2.11.6" libraryDependencies ++= { val akkaV = "2.3.9" val sprayV = "1.3.3" Seq( "io.spray" %% ...

Read More »

Building a war with spray-servlet

akka-logo

We will use spray-servlet to build a war file of our API. So we can run it in a java app server. I assume we already have a working REST API. We will need a web.xml, under src/main/webapp/WEB-INF/: <?xml version="1.0"?> <web-app> <listener> <listener-class>spray.servlet.Initializer</listener-class> </listener> <servlet> <servlet-name>SprayConnectorServlet</servlet-name> <servlet-class>spray.servlet.Servlet30ConnectorServlet</servlet-class> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>SprayConnectorServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app> We need an sbt plugin to ...

Read More »

Building a rest api with spray

akka-logo

Building a rest api with akka and spray is easy. This is how I did it: SprayApiApp:                   import akka.actor.{ActorSystem, Props} import akka.io.IO import akka.pattern.ask import akka.util.Timeout import spray.can.Http import scala.concurrent.duration._ object SprayApiApp extends App { //we need an ActorSystem to host our application in implicit val system = ActorSystem("SprayApiApp") //create apiActor ...

Read More »

A reactive and performant Spray + Akka solution to “Playing with concurrency and performance in Java and Node.js”

akka-logo

In my previous post I examined a fictitious trading engine and compared a Java based blocking solution to a Node.js based non-blocking solution. At the end of the post I wrote that: I suspect that following the recent success of Node.js, more and more asynchronous Java libraries will start to appear. Well such libraries already exist, for example: Akka, Spray, ...

Read More »

ReactiveMongo with Akka, Scala and websockets

akka-logo

I was looking for a simple websocket server for one of my projects to test some stuff with reactive mongo. When looking around, though, I couldn’t really find a simple basic implementation without including a complete framework. Finally I stumbled upon one of Typesage activtor projects: http://typesafe.com/activator/template/akka-spray-websocket. Even though the name implies that spray is required, it actually uses websocket ...

Read More »

Use reactive streams API to combine akka-streams with rxJava

akka-logo

Just a quick article this time, since I’m still experimenting with this stuff. There is a lot of talk around reactive programming. In Java 8 we’ve got the Stream API, we got rxJava we got ratpack and Akka has got akka-streams. The main issue with these implementations is that they aren’t compatible. You can’t connect the subscriber of one implementation ...

Read More »

Akka Notes – Actor Supervision – 8

akka-logo

Failures are more like a feature among distributed systems. And with Akka’s let it crash fault tolerance model, you could achieve a clear separation between your business logic and your failure handling logic (supervision logic). All with very little effort. It’s pretty amazing. This is the topic of our discussion now. Actor Supervision Imagine a method call stack and the ...

Read More »

Clustering reactmq with akka-cluster

akka-logo

In the last two posts on reactmq, I described how to write a reactive, persistent message queue. The queue has the following characteristics:                   there is a single broker storing the messages, with potentially multiple clients, either sending or receiving messages provides at-least-once-delivery; receiving a message blocks the message; unless it is ...

Read More »

Akka Notes – DeathWatch – 7

akka-logo

When we talked about Actor lifecycle, we saw that Actors could be stopped by various means (using ActorSystem.stop or ActorContext.stop or sending a PoisonPill – there’s also the Kill and the gracefulStop). Whatever reason an Actor dies, there are cases when a few other actors in the system would like to know about it. Let’s take a trivial example of ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close