Let's say that I have a stream of objects, that I process and ultimately persist to a db.
That stream could be "never ending", message subscription for an example.
And during that processing I wish to implement some aggregation as a side effect.
For an example, let's say there is a shared resource for the global processing count.
There is one counter per subscription (essentially per Flux stream), but also a shared one.
How can I access that shared resource in a safe and performant way?
I must stress that this shared resource should be accessible at "all" times.
If it were an imperative approach, I'd spin a thread pool / executors and route messages based on say id.
Those counters can be then thread local variables, and I need not bother with concurrency.
Or something like that.
As far as I know, the threading model does not guarantee that all operations will be executed on the same thread.