I'm implementing a system for syncing users from a web service that returns json.The first part with using the scheduler wasn't hard.so the actor runs every five minutes.
and using plays WS library it wasn't hard to get the json.But I have some questions about best practices.LayoutI've now got everything in one actor, it calls a webservice, parses the json response into user objects, and sync these users with mongodb.Should I separate it into one supervisor actor that spawns a web service actor that when it returns spawns a user parser actor that when it returns spawns a db sync actor?
How would something like this look, and what happens if the web service actor fails, or the user parser fails?
The web serviceShould I be using plays built in WS library which is built on top of https://github.com/sonatype/async-http-clientSince this library itself is built on top of Futures...
object NettyFutureBridge {
import akka.dispatch.{ Promise, Future, ExecutionContext }
import java.util.concurrent.CancellationException
def apply(createFuture: ⇒ ChannelFuture)(implicit ec: ExecutionContext): Future[Channel] = {
val p = Promise[Channel]()
createFuture.addListener(new ChannelFutureListener {
def operationComplete(future: ChannelFuture): Unit = try {
if (future.isSuccess) p.success(future.getChannel)
else if (future.isCancelled) throw new CancellationException
else throw future.getCause
} catch {
case t ⇒ p failure t
}
})
p.future
}
}
What are you guys using to call web services?
I know it's a lot of questions, I hope someone has time to answer them.Ps.I am truly impressed the typesafe stack and the documentation for akka is extremely detailed which has helped alot :)
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/ErdzTMJro_4J.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
What are you guys using to call web services?I fortunately don't call webservices anymore. I used to use Axis, but SOAP is just junk IMHO.