Support for independent nested session scoping (out-of-scope transactions)
Description
At the moment all calls to methods annotated with @SessionRequired execute in the same transaction, which is started by the outer most call in the hierarchy of calls. There is also support to restrict nested scopes. However, there are cases where it would be useful to have some session-managed methods executed out-of-scope of the current session.
For example, the streaming companion object API automatically starts a new session (aka transaction) if there is no active one, and as the result, all methods that operate on the streamed data must execute in the same scope. The only way currently to perform data processing in a separate session, is to collect all the streamed data, which defeats the use of streams in such cases. There could be situations where a large set of data needs to be processed independently while having that data streamed to maintain low level of memory usage instead of loading all that data at once.
Session handling needs to be enhanced to support out-of-scope execution. This can be achieved by executing methods identified by such out-of-scope sessions on a separate thread (a separate dedicated thread pool is required for this). It is important that the context for such executions is properly initialised, including the information about the current user, executing the call.
Expected outcome
Ability to execute sessioned methods in the out-of-scope mode.