Question

I need to open many socket connections to some devices, and all of them should stay open for all the time (e.g. 100 socket connections). I also have some business logic written in play framework (2.2).

What will happened if I open some threads for this sockets, for example one thread per socket, or how can I create new thread outside play threading pool?

Was it helpful?

Solution

You can use AKKA to accomplish want you want: http://www.playframework.com/documentation/2.2.x/JavaAkka

Here is a nice start for sockets and AKKA usage under Play2 samples: https://github.com/playframework/playframework/tree/master/samples/java/websocket-chat

In your case, I would create a "Manager" actor and "SocketHandler" actor. Manager actor would create many "SocketHandler" actors as its children and every SocketHandler would manage one or more sockets.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top