Skip to content

Reactive adapter adapter [PoC Only Do not merge] #2433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

garyrussell
Copy link
Contributor

No description provided.

PoC - adapt SI message-driven adapters to send one initial message with a flux payload
during startup and then send messages via the flux as they arrive.

The test case shows 2 services, one that updates the flux and a second one that subscribes
to the modified flux.
@@ -182,6 +200,13 @@ protected void onInit() {
*/
@Override
protected void doStart() {
if (this.reactive && this.flux == null) {
this.flux =
Flux.<Message<?>>create(emitter -> this.sink = emitter, FluxSink.OverflowStrategy.IGNORE)
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 not recommended to leak emitter. Use one of the Processors:
https://projectreactor.io/docs/core/release/reference/#processors

Copy link
Member

Choose a reason for hiding this comment

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

Actually we've been advised exactly opposite: the processors are going to go away from Reactor Core, so would be better to rely on the similar structure provided by the Flux.create().

Anyway this PR is too old and really deserves revisiting one day.

I hope you'll come up soon with the Flux.fromQueue() as we discussed recently in call, so we would have a natural back-pressure for the constantly emitting source.

Thank you for feedback, @bsideup , anyway!

Copy link
Contributor

Choose a reason for hiding this comment

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

They are not going away, this is a misunderstanding. Flux.fromQueue won't give you backpressure I think, the processes is the way to go :)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah... Let's reconsider that in the next milestone!
We have a lot of similar Flux.create() here in Spring Integration.

I'll ping you later if needed.

Thank you, Sergey, again!

Copy link
Contributor

Choose a reason for hiding this comment

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

np! Feel free to assign me as a reviewer, or ask for more info directly 👍

@artembilan
Copy link
Member

With the MessageProducerSupport.subscribeToPublisher(Publisher<? extends Message<?>>) and FluxMessageChannel combination introduced in the #3240 we should think about closing this PR.
The more I look into this the more I'm sure such a channel bypassing approach fully breaks the Spring Integration purpose.
If you definitely would like to handle as a Publisher, it would be better to inject (currently) a FluxMessageChannel into your service and process it respectively using Reactor or RxJava operators.
This way we still keep a loosely-coupled principle between endpoint and would have all the tracking and metrics information on Spring Integration graph.

We definitely may think about a @ServiceActivator + Publsiher method parameter approach against an input channel (independently Flux it or not), but seems for me that may be possible already after introducing a @Reactive marker on that annotation (or method level like an @EndpointId). See #2031 .

Thoughts?

Thanks

@artembilan artembilan added the status: waiting-for-reporter Needs a feedback from the reporter label Apr 7, 2020
@artembilan
Copy link
Member

Another argument against this PR is with Java DSL's:

	/**
	 * Populate a {@link FluxMessageChannel} to start a reactive processing for upstream data,
	 * wrap it to a {@link Flux}, apply provided {@link Function} via {@link Flux#transform(Function)}
	 * and emit the result to one more {@link FluxMessageChannel}, subscribed in the downstream flow.
	 * @param fluxFunction the {@link Function} to process data reactive manner.
	 * @param <I> the input payload type.
	 * @param <O> the output type.
	 * @return the current {@link BaseIntegrationFlowDefinition}.
	 */
	@SuppressWarnings(UNCHECKED)
	public <I, O> B fluxTransform(Function<? super Flux<Message<I>>, ? extends Publisher<O>> fluxFunction) {

@artembilan
Copy link
Member

Superseded with #3503

@artembilan artembilan closed this Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-reporter Needs a feedback from the reporter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants