Add ReactiveMessageSourceProducer (#3254)
* Add `ReactiveMessageSourceProducer` The `ReactiveMessageSourceProducer` wraps a provided `MessageSource` into a `Flux` for subscription in the `subscribeToPublisher(Publisher<? extends Message<?>>)` to make a source polling feature fully based on a reactive, on demand solution * Introduce a `IntegrationReactiveUtils` replacing existing `MessageChannelReactiveUtils` with more functionality * Replace a deprecated `MessageChannelReactiveUtils` with a new `IntegrationReactiveUtils` * Test and document the feature * * Fix Docs typos * * Remove unused imports from `MessageChannelReactiveUtils` * * Fix JavaDoc copy/paste artifact
This commit is contained in:
@@ -89,6 +89,17 @@ The channel adapter goes to a stopped state when a subscription to the `Publishe
|
||||
Calling `stop()` on such a channel adapter completes the producing from the source `Publisher`.
|
||||
The channel adapter can be restarted with automatic subscription to a newly created source `Publisher`.
|
||||
|
||||
=== Message Source to Reactive Streams
|
||||
|
||||
Starting with version 5.3, a `ReactiveMessageSourceProducer` is provided.
|
||||
It is a combination of a provided `MessageSource` and event-driven production into the configured `outputChannel`.
|
||||
Internally it wraps a `MessageSource` into the repeatedly resubscribed `Mono` producing a `Flux<Message<?>>` to be subscribed in the `subscribeToPublisher(Publisher<? extends Message<?>>)` mentioned above.
|
||||
The subscription for this `Mono` is done using `Schedulers.boundedElastic()` to avoid possible blocking in the target `MessageSource`.
|
||||
When the message source returns `null` (no data to pull), the `Mono` is turned into a `repeatWhenEmpty()` state with a `delay` for a subsequent re-subscription based on a `IntegrationReactiveUtils.DELAY_WHEN_EMPTY_KEY` `Duration` entry from the subscriber context.
|
||||
By default it is 1 second.
|
||||
If the `MessageSource` produces messages with a `IntegrationMessageHeaderAccessor.ACKNOWLEDGMENT_CALLBACK` information in the headers, it is acknowledged (if necessary) in the `doOnSuccess()` of the original `Mono` and rejected in the `doOnError()` if the downstream flow throws a `MessagingException` with the failed message to reject.
|
||||
This `ReactiveMessageSourceProducer` could be used for any use-case when a a polling channel adapter's features should be turned into a reactive, on demand solution for any existing `MessageSource<?>` implementation.
|
||||
|
||||
=== Splitter and Aggregator
|
||||
|
||||
When an `AbstractMessageSplitter` gets a `Publisher` for its logic, the process goes naturally over the items in the `Publisher` to map them into messages for sending to the `outputChannel`.
|
||||
|
||||
@@ -27,6 +27,13 @@ See its JavaDocs and <<./graph.adoc#integration-graph,Integration Graph>> for mo
|
||||
The `ReactiveMessageHandler` is now natively supported in the framework.
|
||||
See <<./reactive-streams.adoc#reactive-message-handler,ReactiveMessageHandler>> for more information.
|
||||
|
||||
|
||||
[[x5.3-reactive-message-source-producer]]
|
||||
==== `ReactiveMessageSourceProducer`
|
||||
|
||||
The `ReactiveMessageSourceProducer` is a reactive implementation of the `MessageProducerSupport` to wrap a provided `MessageSource` into a `Flux` for on demand `receive()` calls.
|
||||
See <<./reactive-streams.adoc#reactive-streams,Reactive Streams Support>> for more information.
|
||||
|
||||
[[x5.3-java-dsl-extensions]]
|
||||
==== Java DSL Extensions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user