scalaz
scalaz

Reputation: 81

reuse running process with Java || Scala

main aim = minimize time of execution process.

Want to create system process with running some programm, and reuse it.

For example

command = "/client.exe -ip=127.0.0.1 -port=1234" + somecommand

execute it

Process(command).lineStream.mkString

Result of execution is very slow.

How can I run client.exe once, and reuse this process. Just send some new commands every time to the existing process client.exe.

Any ideas how to increase speed of execution ?

Thanks.

Upvotes: 3

Views: 301

Answers (2)

Andrey Filyanin
Andrey Filyanin

Reputation: 87

if client.exe has sequential execution and it is designed to quit after work done, then You can't do much. Executable should be written to handle interprocess communication.

Upvotes: 1

Hüseyin Zengin
Hüseyin Zengin

Reputation: 1226

What you want is actually interprocess communication and/or remote procedure call. You can use several methods to achieve this. Some of them are:

  1. Using REST/HTTP, spray is probably simplest and best solution for this.

  2. Using Akka, Akka supports remote actors, this means you can spawn an actor on the main process and access it from other processes and send/receive messages.

  3. If you are on a *nix system you can use raw sockets.

  4. Use a message queue, check RabbitMQ

Upvotes: 2

Related Questions