Question

Does anybody know of a place where I could find an example of the classical "chat" application, using Akka Futures with Scalatra 2.1? The Futures example in the documentation is a bit trivial, and since I am completely new to Akka, and relatively new to Scalatra, I wanted to start with a solid foundation. I know this may be hard, since Scalatra 2.1 is still officially in development.

Was it helpful?

Solution

A chat example is vastly different from async requests.

An async request as the case is for the akka futures is a request that resumes and completes in the end. With a Chat example your request needs to resume/suspend it's essentially comet.

with raw servlet 3.0 it looks like this:

https://github.com/scalatra/scalatra/blob/2.1.x/example/src/main/scala/org/scalatra/Servlet30ChatExample.scala

You can then use an akka actor to feed the message queue etc. But the way we support akka futures to kick of async is a suspend/complete scenario and not a suspend/resume/suspend one.

we also have an example with atmosphere/meteor: https://github.com/scalatra/scalatra/blob/2.1.x/example/src/main/scala/org/scalatra/MeteorChatExample.scala

It's a bit less verbose than the servlet 3.0 example

I hope this helps clarifying the parts a bit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top