You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add example to Spring Integration with Reactive Streams
* Add outbound channel adapter example
* Add an example for the `CustomReactiveMessageHandler` usage
* Emphasize that the examples are for Reactive Streams
* Fix a missing letter that caused the text to get inside the code block
* Emphasize that the first example is an event driven inbound channel adapter
* Fix a redundant question mark from the example code
Copy file name to clipboardExpand all lines: src/reference/asciidoc/reactive-streams.adoc
+139-4
Original file line number
Diff line number
Diff line change
@@ -160,12 +160,147 @@ When the target protocol for integration provides a Reactive Streams solution, i
160
160
An inbound, event-driven channel adapter implementation is about wrapping a request (if necessary) into a deferred `Mono` or `Flux` and perform a send (and produce reply, if any) only when a protocol component initiates a subscription into a `Mono` returned from the listener method.
161
161
This way we have a reactive stream solution encapsulated exactly in this component.
162
162
Of course, downstream integration flow subscribed on the output channel should honor Reactive Streams specification and be performed in the on demand, back-pressure ready manner.
163
-
This is not always available by the nature (or the current implementation) of `MessageHandler` processor used in the integration flow.
163
+
164
+
This is not always available by the nature (or with the current implementation) of `MessageHandler` processor used in the integration flow.
164
165
This limitation can be handled using thread pools and queues or `FluxMessageChannel` (see above) before and after integration endpoints when there is no reactive implementation.
165
166
166
-
A reactive outbound channel adapter implementation is about initiation (or continuation) of a reactive stream to interaction with an external system according provided reactive API for the target protocol.
167
-
An inbound payload could be a reactive type per se or as an event of the whole integration flow which is a part of reactive stream on top.
168
-
A returned reactive type can be subscribed immediately if we are in one-way, fire-and-forget scenario, or it is propagated downstream (request-reply scenarios) for further integration flow or an explicit subscription in the target business logic, but still downstream preserving reactive streams semantics.
167
+
An example for a reactive **event-driven** inbound channel adapter:
168
+
```java
169
+
public class CustomReactiveMessageProducer extends MessageProducerSupport {
170
+
171
+
private final CustomReactiveSource customReactiveSource;
172
+
173
+
public CustomReactiveMessageProducer(CustomReactiveSource customReactiveSource) {
174
+
Assert.notNull(customReactiveSource, "'customReactiveSource' must not be null");
A reactive outbound channel adapter implementation is about the initiation (or continuation) of a reactive stream to interaction with an external system according to the provided reactive API for the target protocol.
239
+
An inbound payload could be a reactive type per se or as an event of the whole integration flow which is a part of the reactive stream on top.
240
+
A returned reactive type can be subscribed immediately if we are in a one-way, fire-and-forget scenario, or it is propagated downstream (request-reply scenarios) for further integration flow or an explicit subscription in the target business logic, but still downstream preserving reactive streams semantics.
241
+
242
+
An example for a reactive outbound channel adapter:
243
+
```java
244
+
public class CustomReactiveMessageHandler extends AbstractReactiveMessageHandler {
245
+
246
+
private final CustomEntityOperations customEntityOperations;
247
+
248
+
public CustomReactiveMessageHandler(CustomEntityOperations customEntityOperations) {
249
+
Assert.notNull(customEntityOperations, "'customEntityOperations' must not be null");
Currently Spring Integration provides channel adapter (or gateway) implementations for <<./webflux.adoc#webflux,WebFlux>>, <<./rsocket.adoc#rsocket,RSocket>>, <<./mongodb.adoc#mongodb,MongoDb>> and <<./r2dbc.adoc#r2dbc,R2DBC>>.
171
306
The <<./redis.adoc#redis-stream-outbound,Redis Stream Channel Adapters>> are also reactive and uses `ReactiveStreamOperations` from Spring Data.
0 commit comments