I have a web service that launches a series of actions. All these actions, starting with the same request, consist in sharing an actionContext, which contains some locks and some other information.
So far, this actionContext has been introduced by Spring in all actions using the Request scope.
Now I am implementing a web socket service to be able to follow the evolution of these actions.
Now the WebService will need to create a thread that processes the execution of the actions and returns the webSocket address to the calling application / user.
The action was implemented using the @async Spring annotation and will be run in the thread pool, as defined in the application context.
PROBLEM:
With this new functionality, the request area no longer works, since the spawned thread is not a request (Spring blocks execution).
What is the best solution to solve this problem?
- Implement my stream scope to handle actionContext and correctly inject it into all actions?
- Pass actionContext everywhere manually (in my opinion this does not look very good)
- Implement a web service that creates an instance of webSocket and request the caller to call it as the first, and then pass its link to a real web service?
Thanks for the help!
source share