Skip to content
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

Support Java 9 Flow and ReactiveStream #257

Closed
hantsy opened this issue Jul 21, 2022 · 4 comments
Closed

Support Java 9 Flow and ReactiveStream #257

hantsy opened this issue Jul 21, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@hantsy
Copy link

hantsy commented Jul 21, 2022

We have moved to Java SE 11 since Jakarta EE 10, we should consider more new APIs in specs provided in the new Java SE to modernize our Jakarta EE applications.

Such as use Flow( and adapters of ReactiveStreams) as asynchronous method return type.

@smillidge smillidge added this to the 3.1 milestone Oct 21, 2022
@smillidge smillidge added the enhancement New feature or request label Dec 19, 2022
@mswatosh mswatosh self-assigned this Oct 16, 2023
@mswatosh
Copy link
Member

Hi @hantsy
Thanks for opening this, it's always good to evaluate the new java.util.concurrent APIs. I've been experimenting with the Flow API, and I'm not sure there's anything for the Jakarta Concurrency spec to add here. Since SubmissionPublisher uses an Executor to publish items, it's very easy to provide a ManagedExecutor to access Jakarta Context in the Subscribers. You can see some of my testing here: https://github.com/OpenLiberty/open-liberty/blob/dd23ca159fce78f9f5322936c5da0f02bfb17506/dev/com.ibm.ws.concurrent_fat_reactive/test-applications/reactiveapp/src/reactiveapp/web/ConcurrentReactiveServlet.java

The problem I'm seeing with providing Flow APIs as asynchronous return types is we would need to provide an implementation of Flow.Publisher, and Publisher implementations seem to vary quite a bit depending on how they're used. Maybe I'm missing something here, so let me know if you think there's a way the Concurrency spec could provide value with the Flow APIs

@hantsy
Copy link
Author

hantsy commented Oct 18, 2023

The problem I'm seeing with providing Flow APIs as asynchronous return types is we would need to provide an implementation of Flow.Publisher, and Publisher implementations seem to vary quite a bit depending on how they're used. Maybe I'm missing something here, so let me know if you think there's a way the Concurrency spec could provide value with the Flow APIs

In the Jakarta EE providers like OpenLIberty, I think it is possible to implement the Flow Api handling internally use Smallrey Mutiny, or other reactive streams libs, such as Reactor, Rxjava etc. which also easily converts between JDK Flow and ReactiveStreams API.

@hantsy
Copy link
Author

hantsy commented Oct 18, 2023

Spec should allow use Flow.Publishser as return type(in CDI bean, or REST etc.) like the existing CompletableFuture/ComplationStage, and provides built-in mechanism or public API to transfer state between contexts.

@mswatosh
Copy link
Member

Support for Flow has been added in #368 and #375
I'll open a separate issue for the TCK updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants