For REST call, we can use Request-scoped
bean and RequestContextHolder
to access the HTTP request context.
For message-driven microservices using Spring Cloud Stream, what are the equivalent bean scope and context holder that we can use to access the message context?
Asked
Active
Viewed 454 times
2

wltheng
- 750
- 1
- 11
- 26
-
There is no such scope; what do you mean by "message context" ? – Gary Russell Aug 28 '17 at 13:54
-
2@GaryRussell The `message context` that I imagine is a context that only lives within the message handling span. I am looking for a way to initialize a bean when we receive a message, and destroy the bean when the message is handled. – wltheng Aug 29 '17 at 07:32
-
There's no such facility; you would need a custom scope; it's probably simpler to use a `ThreadLocal`. – Gary Russell Aug 29 '17 at 13:19