Java反应框架的比较 [英] Comparison of Java reactive frameworks

查看:128
本文介绍了Java反应框架的比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到许多框架/库声称它们可以帮助构建Java响应式应用程序,例如:Akka,Vert.x,RxJava,Reactor,QBit等。



它们似乎具有不同的方法,功能,优点和缺点等。我找不到详细的比较。有关于每个框架的文档,但是不足以让我了解它们之间的区别。



主要的Java反应框架之间有什么区别?

>

又有什么应用需求可以推动Java反应框架的选择?



感谢您的时间。

解决方案

我正在研究RxJava,并且做了一些最近对Akka-Streams和Reactor的评估



据我所知所有库,它们都汇聚为一个名为 Reactive-Streams 的单一概念,因此您可以来回切换



我相信 RxJava 是所有类中最通用的,对其他库的依赖为零,并且对并发性没有看法。主要由于其他库/框架(例如Retrofit)的支持,它在Android上非常受欢迎。 1.x分支没有实现Reactive-Streams,但具有包装器,而2.x本身就兼容Reactive-Streams(当前在预览中可用)。许多流行的基于JVM的编程语言都具有适配器(Scala,Kotlin,Clojure等)。



Reactor 与Reactive-Streams兼容,这是较新的图书馆。他们具有对许多其他库的依赖/支持。在流的并发和排队方面,他们选择了一组不同的权衡(即LMAX Disruptor风格)。它与RxJava在运算符之间来回走动,我们已经开始谈论共享运算符池。



Akka 由类似Scala的概念主导;使它正常工作有点麻烦。它背后的团队参与了Reactive-Streams规范的开发,并且有一个Akka-Streams库被宣传为支持Reactive-Streams,但是,访问它很麻烦,因为其流利的API与Akka actor模型紧密地交织在一起。 / p>

如果您是服务器/台式机/ Android方面的用户,RxJava通常是一个不错的选择(我相信它的文档记录比其他更好),并且旨在实现高吞吐量异步操作。如果您更多地在延迟方面,Reactor可能是一个更好的选择。我对Akka-Streams的用法了解不多,但是一年前我看到一个基准测试,其中围绕Akka构建的Web服务器的性能优于Tomcat和Netty + RxJava。


I see many frameworks/libraries that claim that they can help build reactive applications in Java, such as: Akka, Vert.x, RxJava, Reactor, QBit, etc.

They seem to have different approaches, features, pros, cons, etc. I could not find detailled comparisons. There is documentation about each of these framerwork, but it is not enough for me to understand the differences.

What are the differences between the major Java reactive frameworks?

And what are the application requirements that can drive the choice of a Java reactive framework?

Thank you for your time.

解决方案

I'm working on RxJava and I did some evaluations on Akka-Streams and Reactor recently.

As far as I can tell with all the libraries, they converge to a single concept called Reactive-Streams so you can go back and forth between the implementations.

I believe RxJava is the most generic of all, has zero dependencies on other libraries and is not opinionated about concurrency. It is very popular on Android mainly due to support by other libraries/frameworks such as Retrofit. The 1.x branch doesn't implement Reactive-Streams but has wrappers for it whereas 2.x is natively Reactive-Streams compliant (currently available in preview). Many popular JVM-based programming languages have adaptors for it (Scala, Kotlin, Clojure, etc).

Reactor is Reactive-Streams compliant as it is more recent library. They have dependencies/support for a lot of other libraries. They chose a different set of tradeoffs when it comes to concurrency and queueing in the streams (i.e., LMAX Disruptor-style). There were a few back and forth between it and RxJava regarding operators and we've started talking about having a shared pool of operators.

Akka is highly dominated by Scala-like concepts; I had a small trouble getting it to work. The team behind it were involved in developing the Reactive-Streams specification and there is an Akka-Streams library that is advertised to support Reactive-Streams, however, accessing it is cumbersome because its fluent API is heavily intertwined with the Akka actor model.

If you are on the server/desktop/Android side, RxJava is generally a good choice (and I believe is documented better than the others) and is aimed at high-throughput asynchronous operations. If you are more on the latency side, Reactor might be a better choice. I don't know much about the usages of Akka-Streams but I saw one benchmark a year ago where a web-server built around Akka outperformed Tomcat and Netty+RxJava.

这篇关于Java反应框架的比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆