Skip to content

Conversation

artembilan
Copy link
Member

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

@artembilan artembilan added this to the 5.3 RC1 milestone Apr 22, 2020
Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few doc polishes.


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<?>>)` mention above.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mentioned

Internally it wraps a `MessageSource` into the repeatedly resubscribed `Mono` producing a `Flux<Message<?>>` to be subscribed in the `subscribeToPublisher(Publisher<? extends Message<?>>)` mention 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 a 1 second.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is 1 second.

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 a 1 second.
If the `MessageSource` produces messages with a `IntegrationMessageHeaderAccessor.ACKNOWLEDGMENT_CALLBACK` information in headers, it is acknowledged (if necessary) in the `doOnSuccess()` of the original `Mono` and rejected in the `doOnError()` if downstream flow throws a `MessagingException` with failed message to reject.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the headers

if the downstream flow throws

with the failed messagee

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 a 1 second.
If the `MessageSource` produces messages with a `IntegrationMessageHeaderAccessor.ACKNOWLEDGMENT_CALLBACK` information in headers, it is acknowledged (if necessary) in the `doOnSuccess()` of the original `Mono` and rejected in the `doOnError()` if downstream flow throws a `MessagingException` with failed message to reject.
This `ReactiveMessageSourceProducer` could be used for any use-case when a polling channel adapter features should be turned into a reactive, on demand solution for any existing `MessageSource<?>` implementation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a polling channel adapter's features

[[x5.3-reactive-message-source-producer]]
==== `ReactiveMessageSourceProducer`

The `ReactiveMessageSourceProducer` is a reactive implementation of the `MessageProducerSupport` to wrap a provided `MessageSource` into the `Flux` for on demand `receive()` calls.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

into a Flux

@artembilan artembilan force-pushed the ReactiveMessageSourceProducer branch from 7ff705c to 559474f Compare April 23, 2020 16:07
@artembilan artembilan requested a review from garyrussell April 23, 2020 16:07
@garyrussell
Copy link
Contributor

See travis (checkstyle).

@garyrussell
Copy link
Contributor

> Task :spring-integration-core:javadoc
/home/travis/build/spring-projects/spring-integration/spring-integration-core/src/main/java/org/springframework/integration/util/IntegrationReactiveUtils.java:109: error: unknown tag: T
	 * @param <T> <T> the expected payload type.
	              ^
1 error

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
@artembilan artembilan force-pushed the ReactiveMessageSourceProducer branch from c4644a6 to 9b1fabf Compare April 23, 2020 18:25
@artembilan
Copy link
Member Author

Pushed the fix as well.
And I have ran check api task locally 😉

@garyrussell garyrussell merged commit 02407f7 into spring-projects:master Apr 23, 2020
akuma8 pushed a commit to akuma8/spring-integration that referenced this pull request May 9, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants