简体   繁体   English

Java和NodeJS如何在后端进行通信?

[英]How Java and NodeJS communicate in backend?

I have already done a project using jsp as backend, while the business logic in backend is implemented by java. 我已经使用jsp作为后端完成了一个项目,而后端的业务逻辑则由java实现。 Now I want to rewrite this project.I hope the part of backend communicating with browser is implemented with nodejs and the business logic in backend still use java to implement.Now I met with a problem about how to communicate between nodejs and java in backend. 现在我想重写这个项目。我希望后端与浏览器通信的部分是用nodejs实现的,后端的业务逻辑仍然使用java来实现。现在我遇到了一个关于如何在后端的nodejs和java之间进行通信的问题。 Is there any feasible solution? 有没有可行的解决方案? Thanks 谢谢

Node.js is a standalone runtime environment (based on V8, which is implemented in C++). Node.js是一个独立的运行时环境(基于V8,它是用C ++实现的)。 Since it is not based on Java technology it has no "simple" way to communicate with Java code running in a JVM. 由于它不基于Java技术,因此没有“简单”的方式与在JVM中运行的Java代码进行通信。

Integrating unrelated technologies, such as these two, is typically done by using some sort of inter-process communication , for example, TCP sockets or a message queue with bindings native to each platform (eg zeromq ). 集成不相关的技术(例如这两者)通常通过使用某种进程间通信来完成 ,例如,TCP套接字或具有每个平台本地绑定的消息队列(例如zeromq )。 Creating a JNI interface is another possible option. 创建JNI接口是另一种可能的选择。

Searching the web for keywords such as "node.js java bridge" yields a number of interesting results. 在网上搜索“node.js java bridge”等关键字会产生许多有趣的结果。

I think u can check this 我想你可以检查一下

https://www.npmjs.com/package/java https://www.npmjs.com/package/java

Using this you can call method of java from node.js 使用它,您可以从node.js调用java的方法

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

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