简体   繁体   English

Java 应用程序与 node.js 服务器通信的最佳反应方式

[英]Best reactive way for a Java application to communicate with a node.js server

I need a node.js server to run a third-party library which is great at interacting reactively with the ethereum blockchain.我需要一个 node.js 服务器来运行一个非常擅长与以太坊区块链交互的第三方库。 They don't have a Java implementation but my application is Java-based.他们没有 Java 实现,但我的应用程序是基于 Java 的。

I need to make a call from my JVM container to the node.js container and have the result returned in a reactive way.我需要从我的 JVM 容器调用 node.js 容器并以反应方式返回结果。

Which pattern/protocol should I use to implement this effectively?我应该使用哪种模式/协议来有效地实现这一点? eg A message bus, websockets, REST?例如消息总线、websockets、REST?

There are a lot of theories about it, and it is also hard identifying which is the "best protocol" for it;关于它有很多理论,也很难确定哪个是它的“最佳协议”; it really depends by the use cases.这真的取决于用例。 In my company we have several microservices fully reactive that are communicating between each other via Websocket (using Webflux, Spring 5).在我的公司中,我们有几个完全反应式的微服务,它们通过 Websocket(使用 Webflux、Spring 5)相互通信。

In your case (without the use cases I can't be detailed) the main benefit of using Websocket is the entire server is acting in an entirely reactive way, with a completely reactive stack.在您的情况下(没有用例,我无法详细说明)使用 Websocket 的主要好处是整个服务器以完全反应性的方式运行,具有完全反应性的堆栈。

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

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