This feature is based on the Triple protocol and implemented using Project Reactor, supported from version 3.1.0
onwards. Users only need to write an IDL file and specify the corresponding Generator for the protobuf plugin to generate and use Stub code that supports the reactive API.
There are four call modes: OneToOne, OneToMany, ManyToOne, and ManyToMany, corresponding to Unary calls, server streams, client streams, and bidirectional streams, respectively. In Reactor’s implementation, One corresponds to Mono, and Many corresponds to Flux.
Reactive Streams provide a standard asynchronous stream processing API that allows applications to write event-driven programs while ensuring stability through BackPressure. The Triple protocol adds support for streaming scenarios in the Dubbo framework at the communication protocol level, enabling business needs such as large file transfers and push mechanisms.
The combination of Dubbo + Reactive Stream Stub offers the most convenient streaming usage and improved end-to-end asynchronous performance.
Reference use case https://github.com/apache/dubbo-samples/tree/master/dubbo-samples-triple-reactor
The system needs to handle large volumes of concurrent requests without overloading any server. Systems that provide real-time data to a large number of users need to ensure that they can handle the load without crashing or slowing down.
For Triple usage and configuration, please refer to Using Triple with IDL, and ensure Dubbo version >= 3.1.0.
To use Reactor Triple, you need to add the following dependencies.
Simply change mainClass to org.apache.dubbo.gen.tri.reactive.ReactorDubbo3TripleGenerator
, and ensure ${compiler.version}
>= 3.1.0
The IDL file is written in exactly the same way as the native Triple protocol, and the corresponding code will be generated by default in the target/generated-sources/protobuf/java
directory after compilation.
Start Server
Start Consumer