Eduardo
Eduardo

Reputation: 8392

Scalatra 2.1 Akka Futures Example

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.

Upvotes: 3

Views: 1342

Answers (1)

Casual Jim
Casual Jim

Reputation: 1179

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.

Upvotes: 5

Related Questions