-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[Question] Zuul2 - Filter thread safety ? #445
Comments
Anyone has any suggestions ? |
This is a great question. The assumption when building this code was that each request will run on a single thread and will have its own The reason this is ok in practice is because all the async operation for each request (which has its own To answer your first question, yes what you did is correct. You would want to schedule the blocking task on a separate thread pool. |
Now I have the same problem. Once there is an async filter, the context will be confusing when the concurrency is high. |
When async, it does not block. So there are multi threads hold the different SessionContext. It take the wrong SessionContext. I think it should store the relations of the SessionContext for each dealing. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Context:
I am trying to write an async filter that fetches data from a service and store the result in the SessionContext to be consumed by another filter down the line.
Code
Here is my filter code so far:
I actually have two questions:
SessionContext
class, it is not thread safe :Based on my understanding, once the filter enters the
applyAsync()
method, no other zuul thread is interacting with the message object until the observable completes, which means that it would be ok to set the value in the SessionContext from the background thread. Is that correct ?Bottom line, what is the recommended way to store a value in the SessionContext from an async filter ?
The text was updated successfully, but these errors were encountered: