我正在尝试通过JMS / ActiveMQ组件使用Camel-Spring-remoting集成2个spring-mvc应用程序。
我已成功地从App2调用App1中的远程方法。
App1和App2具有共享Web会话(使用Spring-Session / Redis),其中包含currentUserId及其属性等数据。会话的召唤如下:
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
HttpSession session = attributes.getRequest().getSession(false);
session.getSession().getAttribute("SYSTEM_USER_ACCOUNT");
因为远程方法调用是通过JMS进行的,所以App1无法识别以前经过身份验证的HTTP会话,而我在App1中遇到异常
org.apache.camel.RuntimeCamelException: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1556)
at org.apache.camel.component.bean.BeanInvocation.invoke(BeanInvocation.java:87)
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:134)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
.
.
Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131)
at com.keype.hawk.core.api.system.util.SessionUtils.getSession(SessionUtils.java:38)
at com.keype.hawk.core.api.system.util.SessionUtils.getSystemUserAccount(SessionUtils.java:104)
at com.keype.hawk.core.api.system.util.SessionUtils.getStaffId(SessionUtils.java:98)
at com.keype.hawk.core.impl.party.service.PartyServiceImpl.preUpdate(PartyServiceImpl.java:208)
at com.keype.hawk.core.impl.party.service.PartyServiceImpl.updateParty(PartyServiceImpl.java:525)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
这里的做法是什么?如何从JMS调用中访问servlet上下文和当前用户的http-session?