How to get all the Actors that are holding a particular web socket endpoint using Play framework?

15 views
Skip to first unread message

kant kodali

unread,
Mar 19, 2017, 8:08:28 AM3/19/17
to Akka User List
Hi All,

I have a message queue which doesn't have Actor concepts or anything so what I plan to do is that on the application startup I want to start the consumer which will then keep getting messages from the queue. Now, Play framework creates an Actor for every Web Socket Connection and I want to be able to group all the Actors that hold the Web Socket connection for a particular ws endpoint so that I can broadcast all the messages that I received from message queue on particular topic to those group of Actors. 

For Example the following end points will have an Actor created every time a client initiates a request to any of the end point below. so lets call them Foo actors and Bar Actors. 

ws://localshost/foo 

ws://localshost/bar


Now all I want to do is this 

Pseudo code:
   
 messages = ReceiveMessagesFromQueue; // This is a live stream and it never stops.
 for message in messages:
     if message has key1:
           List<FooActors> foo_list = getAllFooActors
           broadcast(message, foo_list)
     else if message has key2:
           List<BarActors> bar_list = getAllBarActors
           broadcast(message, bar_list)

Please Let me know if you have any suggestions on the best way to approach this problem using Play Framework (I am using the latest version).

Thanks!

Akka Team

unread,
Apr 25, 2017, 5:09:22 AM4/25/17
to Akka User List
For more Play Framework specific answers I'd ask on the play mailing list instead.

In general:

If it has to be actors representing the websockets I'd let them register to a registry/broadcast actor that will keep a list of current web sockets (using watch to know if they terminate for example) and forward messages to all currently living web socket actors.

In Akka Streams BroadcastHub will allow you to do something like this without involving actors directly.

-- 
Johan
Akka Team

--
>>>>>>>>>> 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 akka-user+unsubscribe@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.




Reply all
Reply to author
Forward
0 new messages