On Sun, Jun 26, 2016 at 8:59 AM, M Ahsan <[email protected]> wrote:

> First off, I was wondering if it is a correct design decision to run a
> Netty websocket server inside an Akka actor. I want to be able to receive
> messages on the actor, and send them to the clients connected to the Netty
> WS server. Netty has its own thread pools and whatnot, so is it ok to spawn
> a Netty server inside an Akka actor, or is there a better way to approach
> this?
>

You can do that, no problem. Be careful to not use the actor's mutable
state from callbacks running on other threads, though. Perhaps better to
start the Netty server outside of the actor. You have to interact with the
actor using messages anyway.

http://doc.akka.io/docs/akka/2.4.7/general/jmm.html#Actors_and_shared_mutable_state

You could look at Akka Http as an alternative:
http://doc.akka.io/docs/akka/2.4.7/scala/http/routing-dsl/websocket-support.html


>
> Second, my Akka application spawns several WebSocket clients to other
> services. When I get data from the service, I want to publish that data to
> various actors. The WebSocket client I use (async-http-client) uses a
> callback to respond to incoming messages. I'm doing something along these
> lines right now:
>
> http://paste.click/s/GImeFh
>
> Is this correct usage, or is there a better way to approach this as well?
>

That is alright. Same comment here, be careful to not close over the
actor's state.

Alternative:
http://doc.akka.io/docs/akka/2.4.7/scala/http/client-side/websocket-support.html


>
> My real concern here is what I can/can't do in an actor, because I feel
> like these are some common things developers would use in their apps. If
> anybody can clear these issues, that would be great. Thanks!
>
> --
> >>>>>>>>>> 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 https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrik Nordwall
Akka Tech Lead
Lightbend <http://www.lightbend.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>>>>>>>>>      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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to