简体   繁体   English

java spring 服务器和 python 应用程序之间的通信

[英]Communication between java spring server and python applications

I designed my java spring application to run a couple of python programs on same server and communicate with them.我设计了我的 java spring 应用程序来在同一台服务器上运行几个 python 程序并与它们通信。 I run them with ProcessBuilder and communicate via InputStream/OutputStream.我使用 ProcessBuilder 运行它们并通过 InputStream/OutputStream 进行通信。
Now I want to achieve that when I restart or shut down my java application, python apps didnt close.现在我想实现这一点,当我重新启动或关闭我的 java 应用程序时,python 应用程序没有关闭。 I can't get Process object by PID.我无法通过 PID 获取 Process object。 With ProcessHandler object I can't get input/output streams.使用 ProcessHandler object 我无法获得输入/输出流。 It seems that i should use some other mechanism of IPC.看来我应该使用其他IPC机制。 So the questions are:所以问题是:

  1. How can I run external applications from java so they wouldn't close when java app restarts?如何从 java 运行外部应用程序,以便在 java 应用程序重新启动时它们不会关闭?
  2. How can I achieve communication between java and python applications without having Process object?如何在没有进程 object 的情况下实现 java 和 python 应用程序之间的通信?

Thanks in advance, sorry for poor language:)在此先感谢,抱歉语言不好:)

I give some suggestion on our project experience:我对我们的项目经验提出一些建议:

  1. In single server, use docker-compose to run/stop app no matter using java or python.在单服务器中,无论使用 java 还是 python,都可以使用 docker-compose 运行/停止应用程序。 In multi-server,they will be deployed in Istio.在多服务器中,它们将部署在 Istio 中。

  2. use Restful protocol to communicate between them.使用 Restful 协议在它们之间进行通信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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