Using a request scoped bean outside of an actual web request
For Spring 4 Frameworks add servletContext.addListener(new RequestContextListener());
public class WebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { RootConfiguration.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { WebMvcConfiguration.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
@Override
protected Filter[] getServletFilters() {
return new Filter[] { new HiddenHttpMethodFilter() };
}
**@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
servletContext.addListener(new RequestContextListener());
}**
}
You can only use request (and session) -scoped beans on the web container thread on which the request is running.
I presume that thread is waiting for an async reply from your SI flow?
If so, you can bind the request-scoped bean to the message, perhaps in a header, or somewhere in the payload.