I am using Akka/Play(Java) in an system where an Actor needs to write data to outstream and read from blocking input stream. In my current implementation I am using a java thread which does the actual writing/reading to/from streams, the thread in constructed by the actor passing it a self reference. When writing data the actor simply calls
workerthread.write(...)
and upon reading data from blocking input stream the thread calls
actorRef.tell(message, null)
My testing looks ok, but I would like to know if there are better approaches/patterns or any potential problem I would need to be mindful of. I know introducing a worker thread is not optimal, however since the integration is with an stateful system I see no other option
A PinnedDispatcher can be used to guarantee an actor would run on the same thread
https://groups.google.com/forum/#!topic/akka-user/7XRt6nO8XM4