Node.js 和 Scala (Java) 之间的连接器
将 Node.js 与 Scala (Java) 集成的最佳方式是什么?
到目前为止,我看到的最简单的方法是使用 Redis PubSub 作为中介,用 node.js 服务器处理 HTTP 请求并将消息发布到请求通道(通过 redis-node-client)和 Scala Actor(例如 Akka Redis PubSub集成)订阅请求通道并将计算结果发布到响应通道(由节点订阅)。
What is the best way of integrating node.js with Scala (Java)?
The simplest way I see so far is using Redis PubSub as a mediator, with node.js server handling HTTP requests and publishing messages to the request channel (via redis-node-client), and Scala actors (e.g. Akka Redis PubSub integration) subscribed the request channel and publishing computation results to the response channel (subscribed by nodes).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您将使用 JSON 作为消息格式,您将在 lift 框架内发现几个非常好的 JSON 实现(您不必将其用作 Web 框架,您可以愉快地从 lift 中挑选组件) -utils)。
但是,如果您想使用 pubsub/actor 模型(这是一个不错的选择,具体取决于您的需求),那么您可能会做得比 Akka 更糟糕,正如您已经建议的那样。
Assuming you'll be using JSON as your message format, you'll find a couple of very good JSON implementations inside the lift framework (which you don't have to use as a web framework, you can happily cherry-pick components from lift-utils).
But if you want to go with a pubsub/actor model (and it's a good choice, depending on your needs) then you could do a lot worse than Akka, as you already suggested.
我不认为实现 Scala 远程参与者协议的 Node.js 库确实是最好的方法。它可能适合您当前的应用程序,但如果您需要添加第三种技术怎么办?如果需要为每种语言/平台编写特殊的支持库真的是最好的吗?
集成这些的最佳方法是使用通用技术来集成所有语言的应用程序。更具体地说,它支持基于参与者的消息发送。幸运的是,AMQP 和 ZeroMQ 都适合这个空间,并且都可以与 node.js 或 scala 一起使用。此外,AMQP 和 ZeroMQ 的库将比任何特殊用途的节点-scala 连接器更频繁地使用,因此 buigs 将得到修复,并且将支持更新的版本。
I don't think that a node.js library implementing the Scala remote actor protocol is really the best way. It may work well for your current application but what if you need to add a third technology to the mix. Can it really be best if it requires writing special support libraries for each language/platform?
The best way to integrate these is to use a general purpose technology for integrating applications of all languages. And more specifically, one which supports actor-based message sending. Fortunately, AMQP and ZeroMQ both fit into that space and both can be used with node.js or scala. In addition, the libraries for AMQP and ZeroMQ will be more heavily used than any special purpose node-scala connector, therefore buigs will get fixed and newer versions will get supported.
我已经实现了一个小型概念验证库,用于将node.js连接到Scala直接通过 TCP 进行远程 Actor(使用 protobuf 作为编组机制)。
I've implemented a small proof-of-concept library for connecting node.js to Scala Remote Actors directly via TCP (using protobuf as a marshalling mechanism).