4

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.

Eduardo
  • 8,362
  • 6
  • 38
  • 72

1 Answers1

5

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.

Casual Jim
  • 1,179
  • 7
  • 13
  • Wow! Thanks! I was thinking of putting Futures in a list and, every time a relevant message came in, to complete them with the answer. Thank you for all the great work you guys are doing. I have used Scalatra for one of my projects and it works great! – Eduardo Feb 29 '12 at 21:21
  • updated the links to point to the support branch for 2.1. Scalatra is currently at version 2.2.1 and the master branch doesn't have those files anymore – Casual Jim Apr 11 '13 at 11:19