Is there any equivalent of Reactive Extensions (.NET) for Java?
About Rx (Reactive Extensions)
Rx is a library for composing asynchronous and event-based programs using observable collections.
I am aware of rule engines such as Drools from JBOSS, but is there some other way that is closer to the Microsoft .NET approach?
Reactive Extensions: Popularly known as ReactiveX, they provide API for asynchronous programming with observable streams. These are available for multiple programming languages and platforms, including Java where it's known as RxJava.
#1 What is reactive programming in a few words? Reactive programming is a programming paradigm that deals with asynchronous data streams (sequences of events) and the specific propagation of change, which means it implements modifications to the execution environment (context) in a certain order.
RxJava is a Java library that enables Functional Reactive Programming in Android development. It raises the level of abstraction around threading in order to simplify the implementation of complex concurrent behavior.
Reactive programming with Reactor in Java supported us in handling blocking IO (e.g. Kafka, gRPC), backpressure, thread handling/scheduling, and error handling effectively.
RxJava (RX ported by Netflix) is available and stable here: https://github.com/ReactiveX/RxJava.
It even works with Java 8's lambda syntax pretty well! You can do stuff like that:
Observable
.from(Arrays.asList(1, 2, 3, 4, 5))
.filter(val -> val % 2 == 0)
.map(val -> val * val)
.scan(0, (prev, curr) -> prev + curr)
.subscribe(System.out::println)
Pretty cool a?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With