我正在尝试在我的骆驼异常处理程序中获取原始消息。我正在尝试致电
exchange.getUnitOfWork().getOriginalInMessage()
但出现以下异常
java.lang.IllegalStateException: AllowUseOriginalMessage is disabled. Cannot access the original message.
at org.apache.camel.impl.engine.DefaultUnitOfWork.getOriginalInMessage(DefaultUnitOfWork.java:307)
如何启用
AllowUseOriginalMessage
功能?
这可以通过
CamelContext.setAllowUseOriginalMessage(Boolean)
启用
例如:
@Bean
public CamelContext camelContext(ApplicationContext applicationContext, List<RoutesBuilder> routeBuilders) throws Exception {
SpringCamelContext context = new SpringCamelContext(applicationContext);
context.setAllowUseOriginalMessage(true);
for (RoutesBuilder routeBuilder : routeBuilders) {
context.addRoutes(routeBuilder);
}
...
return context;
}
参见 RuntimeConfiguration.setAllowUseOriginalMessage(java.lang.Boolean)