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

How transform ParallelFlowable? #6966

Closed
deripas opened this issue Apr 20, 2020 · 2 comments
Closed

How transform ParallelFlowable? #6966

deripas opened this issue Apr 20, 2020 · 2 comments

Comments

@deripas
Copy link

deripas commented Apr 20, 2020

Hi!
I'm using version rxjava:2.2.19

Faced with the need to have its own context for each thread in parallel processing.
How to do this better?

Sintetic example on RxJava:

        ThreadLocal<Context> context = .... // Thread load context

        Flowable.fromPublisher(...)
                .parallel()
                .runOn(Schedulers.computation())
                .map(item -> transformWithContext(context.get(), item)) // <- map item with current context
                ...
                .sequential()

For example, in Reactor you can use the transformGroups method:

        Flux.from(...)
                .parallel()
                .transformGroups(groupedFlux -> {
                    Context ctx = new ....
                    return groupedFlux
                            .map(item -> transformWithContext(context.get(), item);
                })
                .sequential()

This approach is similar to using groupBy.
I couldn't find an analog to the transformGroupsmethod, or does it exist?

With best regards,
Anton

@akarnokd
Copy link
Member

This type of operation is not supported in RxJava or any of the support libraries and there are no plans to add it.

@akarnokd
Copy link
Member

akarnokd commented Aug 6, 2020

All I can say is that it may happen in the near future as part of RxJavaExtensions: akarnokd/RxJavaExtensions#74

@akarnokd akarnokd closed this as completed Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants