如何将jaxb对象传递给camelconfig xml文件
我正在尝试在骆驼路由中使用 jaxb。我尝试使用 jaxb 从 xml 加载路由器并完成它。在方法内部,我创建了 jaxb 对象并在 xml 中解组路由器(从 xml 加载路由器)。
我的代码:
JAXBContext jaxb = JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
Unmarshaller unmarshaller = jaxb.createUnmarshaller();
Resource rs = new ClassPathResource("cameltest.xml");
Object value = unmarshaller.unmarshal(rs.getInputStream());
RoutesDefinition routes = (RoutesDefinition) value;
context.addRouteDefinitions(routes.getRoutes());
要求:
而不是在 java 文件中执行它。我需要当调用服务中的方法时,方法内的 jaxb 对象应该触发包含流的 xml(路由器概念)。帮我........
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Camel 路由中使用 JAXB 非常简单,如 JAXB。除非处理非常复杂,否则可以在 Spring 中完成,并且需要最少的代码。
您试图从代码中执行的操作是使用 JAXB 从 Camel xml 文件中提取路由,也许您想要创建动态路由器 - 我建议查看 EIP 模式 Camel 实现并选择诸如基于内容的路由器或动态路由器之类的东西。
Using JAXB in a Camel route is quite easy, as is shown in JAXB. Unless the processing is very complex it can be done in Spring and requires a minimal amount of code.
What it looks like you are trying to do from the code is extract the routes using JAXB from the Camel xml file, perhaps you are wanting to create dynamic router - I would suggest looking at the EIP Patterns that Camel implements and picking something like the Content Based Router or Dynamic Router.