Announcement Announcement Module
Collapse
No announcement yet.
How to scope 'request' bean for async (DeferredResult) processing across threads? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to scope 'request' bean for async (DeferredResult) processing across threads?

    Hi all,

    I would like to set a bean for request-like scope access across a request handled asynchronously (using Servlet 3 and DeferredResult), which could be processed by multiple threads. The reason for this is I want to share a 'correlation id' between all of the processing triggered by a single user-initiated request.

    From other forum posts (and blogs) I am assuming that I can't use a standard Request scoped bean, as other Threads responsible for handling the request won't be able to see this bean (although technically the request could still be active, and be waiting for the async dispatcher to return the results - although I guess this can't guaranteed?)

    I've currently used ThreadLocal as a workaround (see my blog for more details http://taidevcouk.wordpress.com/2014...n-spring-boot/), but this feel a bit hacky...

    Has anyone got any advice on how to do this? Any guidance would be most appreciated!

    Best wishes,

    Daniel

  • #2
    This question is probably a better candidate for StackOverflow, perhaps with the "spring" and "spring-mvc" tags.

    Could you post your question there?

    The forums are moving to stackoverflow, a page explaining all this will be available there in a few days: http://spring.io/questions

    Comment

    Working...
    X