> On 07 Sep 2015, at 19:32, Richard Rodseth <[email protected]> wrote:
> 
> Maybe just move the bind call into my routing actor, in response to some sort 
> of Start message ?

Yep.

Here’s a similar example: 
https://github.com/hseeberger/reactive-flows/blob/master/src/main/scala/de/heikoseeberger/reactiveflows/HttpService.scala#L133
 
<https://github.com/hseeberger/reactive-flows/blob/master/src/main/scala/de/heikoseeberger/reactiveflows/HttpService.scala#L133>

Pay attention to not use any actor state/internals in the route, i.e. define 
the route in the companion object.

Cheers
Heiko


> 
> On Mon, Sep 7, 2015 at 8:38 AM, Richard Rodseth <[email protected] 
> <mailto:[email protected]>> wrote:
> I'm trying Akka Http for the first time, coming from Spray. In Spray I have  
> a routing actor which extends HttpService and is passed to HttpBind as shown 
> below. This way routes can create per-request actors as a child of the 
> routing actor.
> What would be the equivalent in Akka Http?
> 
> I'm not so worried about the bind responder stuff right now, but here's what 
> my Spray initialization looks like:
> 
> class BindResponder(service: ActorRef, system:ActorSystem) extends Actor with 
> ActorLogging {
>      def receive = {
>       case b @ Http.Bound(connection) => {
>         log.info <http://log.info/>(s"Successfully bound, starting processing 
> $b")
>         ...
>         self ! PoisonPill
>         
>       }
>       case cf @ Http.CommandFailed(command) => {
>         log.error(s"Binding failed, shutting down process $cf")
>         System.exit(0)
>         // TODO In future we might try to shutdown the actor system cleanly, 
> but
>         // that is non-trivial
>         // system.shutdown()
>       }
>     }
>    
>   }
>   
>    val bindResponder = system.actorOf(Props(new BindResponder(serviceActor, 
> system)))
>   
>   IO(Http)(system).tell(Http.Bind(this.routingActor, hostName, port = 
> servicePort),bindResponder)
> 
> 
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <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] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/akka-user 
> <http://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
>>>>>>>>>>      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.

Reply via email to