Hi Richard,
> The route looks something like this:
>
> post {
>
> val result = (xyzService ?
> XYZService.CreateXYZ(xyzAttributes)).mapTo[Long]
>
> onComplete(result) {
>
> case Success(value) => complete(s"The result was $value")
>
> case Failure(ex) => complete(StatusCodes.InternalServerError, s"An
> error occurred: ${ex.getMessage}")
>
> }
>
>
Isn't there a version of complete() that take a Future directly? (maybe
called completeAsynch, but I think there should be one). I am not sure
calling complete() out of the context of the actor works or not.
-Endre
> }
>
> In this case the XYZService actor forwards a transformed message to the
> DbActor
>
> case msg @ XYZService. CreateXYZ(attributes) => {
>
> dbActor forward DbActor.AddXYZ(attributes) // Interesting that I
> can "forward" a new message
>
> }
>
> If the response needed transforming, presumably an additional ask would be
> needed within the XYZService.
>
> The DbActor replies with a result
>
> case AddXYZ(attributes) => db withSession { implicit session =>
>
> try {
>
> val result = XYZDAO.add(attributes)
>
> sender() ! result
>
> } catch {
>
> case e: Exception =>
>
> sender() ! akka.actor.Status.Failure(e)
>
> throw e
>
> }
>
> }
>
> Does this seem reasonable? Would it be considered better practice to use
> per-request actors for every route, to avoid the use of tell, or somehow
> pass the request context to the service actor for completion? I've read the
> Ian Forsey article, but am a bit unclear on whether to standardize on the
> per-request model. I did notice that the route I implemented using
> per-request is slow on all but the first request, and I haven't had time to
> look into that.
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
--
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.