Skip to content

GH-3635: Add Future<Void> & Mono<Void> to gateway #3899

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

Merged
merged 6 commits into from
Oct 4, 2022

Conversation

artembilan
Copy link
Member

Fixes #3635

When Future<Void> & Mono<Void> is used as a messaging gateway return type, the application hangs out on this barrier which may lead to the out of memory eventually

  • Add support for the Future<Void> & Mono<Void> messaging gateway return type and ensure an asynchronous call for the gateway.send(Message) operation and its exception handling.
    In case of successful call, the Future is fulfilled with null and Mono is completed as empty

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.

Also refer to our out-of-band discussion about a two-way flow that returns one of these types.

@@ -801,7 +800,9 @@ public interface MyGateway {
----
====

Unlike the `Future<?>` return types, there is no way to inform the caller if some exception is thrown by the flow, unless some custom `TaskExecutor` (such as an `ErrorHandlingTaskExecutor`) is associated with the `@Async` annotation.
But downstream exceptions are not going to be propagated back to the caller.
To ensure asynchronous behaviour for downstream flow invocation and exception propagation to the caller, starting with version 6.0, the framework provides support for the `Future<Void>` and `Mono<Void>` return types.
Copy link
Contributor

Choose a reason for hiding this comment

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

American English (behavior).

Fixes spring-projects#3635

When `Future<Void>` & `Mono<Void>` is used as a messaging gateway return type,
the application hangs out on this barrier which may lead to the out of memory eventually

* Add support for the `Future<Void>` & `Mono<Void>` messaging gateway return type
and ensure an asynchronous call for the `gateway.send(Message)` operation and
its exception handling.
In case of successful call, the `Future` is fulfilled with `null` and `Mono` is completed as empty
@garyrussell garyrussell merged commit 5fadaf5 into spring-projects:main Oct 4, 2022
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.

Future<Void> method with @Gateway causes thread leak
2 participants