目前看到绝大多数的Rxjava教程都是在Android上使用的,那在Java服务端呢?Rxjava是否有其应用场景和优势。
阿神2017-04-17 17:34:37
Hystrix uses RxJava’s simple window API to build metrics, which should be considered a good back-end usage scenario.
To be honest, although RxJava is cool, the advantages of using RxJava on the server side are really few.
The main reason is that most Java servers are still based on synchronous logic, and the migration cost is too high.
The responsive advantages of RxJava will only be reflected when asynchronous logic dominates. The mixed use of asynchronous and synchronous, but also It’s better to use NodeJS’s asynchronous processing coordination as a whole.
Secondly, RxJava’s large number of data processing APIs are quite expensive for programmers who are used to synchronization logic.
In addition, most of the back-end class libraries are synchronous APIs, and there are very few class libraries that are compatible with RxJava API.
So there are very few back-end libraries based on RxJava.
The most famous class library currently built based on RxJava in the backend is Hystrix. The API it provides is also called in a synchronous manner through the Command mode. External callers do not need to care about the internal RxJava implementation. This should also be done to reduce user costs. Let’s learn about the cost.
rxjava-jdbc is compatible with RxJava API. Although the code will be much simpler when used, jdbc is rarely used directly in current projects, which is a useless place for heroes.
If you want to use reactive programming in the backend. You might as well take a look at vertx. It basically uses its own responsiveness to open up all aspects of the backend. The technology stack it plans is still very comprehensive, basically covering the functions of backend development.