简体   繁体   中英

Akka input stream handling

I am building a system on akka/play framework with java. I need to build an actor who does a SSH connection to an external system & maintain the session for the span of user interaction..

I found Java JCraft/JSch library that supports java SSH connectivity

  1. Is there a way to wrap JSch input stream as a event driven input stream, hence when data arrives a onmessage(data) event is fired.
  2. Other option I have is to have a worker thread read/wait data from the stream living inside the scope of the actor, is this a good pattern, I am worried a worker thread would reduce scalability significantly
  3. I found akka socket support but not specifically SSH, is there already such a library?

Jsch channels support writing to a given OutputStream

channel.setOutputStream(stream)

As the solution what I did was to write a custom OutputStream that on write(buffer) pass the buffer contents to a given actor via actorRef.tell(buffer, ActorRef.noSender());

thus eliminating the need for a external thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM