Send message TCP / IP AKKA

Can I send a message via TCP / IP to an AKKA actor?

For example, write to the client how:

mySocket = new Socket("theactor", 75); os = new DataOutputStream(smtpSocket.getOutputStream()); os.writeBytes("HELLO"); 

Can this send messages to AKKA actor?

thanks

+4
source share
3 answers

Having developed a bit more response from Viktors, a minimal example would be

 import akka.actor._ import ActorDSL._ import java.net.InetSocketAddress object Server extends App { implicit val sys = ActorSystem("telnet") actor(new Act with ActorLogging { IOManager(context.system) listen new InetSocketAddress(1234) become { case IO.NewClient(server) โ‡’ server.accept() case IO.Read(handle, bytes) โ‡’ log.info("got {} from {}", bytes.decodeString("utf-8"), handle) } }) } 

Then in another launch of the telnet localhost 1234 shell and start typing, you will see one member log message in a line.

+4
source

Yes and no. You will need to use the Akka IO module or the Akka Camel module (with netty or mina):

http://doc.akka.io/docs/akka/snapshot/scala/io.html

http://doc.akka.io/docs/akka/snapshot/java/camel.html

+1
source

If you are trying to send a message through a remote participant using an IP address, why not try the Akka Remote Actor system? "Read here"

0
source

Source: https://habr.com/ru/post/1440601/


All Articles