拆分消息并在骆驼中路由它们
我从队列中读取了一条大型 XML 消息,我需要将其拆分为块并将其转换为对象,然后根据该对象将它们路由到各个目的地。
所以我将routeBuilder配置为
ChoiceDefinition choice = from(routeConfig.getFromEndpoint())
.split().method(xmlSplitter, "splitMessage").streaming().process(xmlProcessor).choice();
for (RouteConfig filter : filters) {
choice = choice.when(header(REPORT_TYPE_HEADER_NAME).contains(filter.getReportTypeHeaderFilter()))
.to(filter.getToEndpoint());
}
choice.otherwise().to(routeConfig.getErrorEndpoint());
但是路由根本没有发生,所有消息都发送到errorEndpoint。 我发现原因是分离器删除了标头,因为它位于路由之前。
看来我不能在路由后使用分割。
解决这个问题的方案是什么?
I have a large XML message read from queue, I need to split it in chunks and convert it into objects and then route them to various destinations based on the object.
So I have configured the routeBuilder to
ChoiceDefinition choice = from(routeConfig.getFromEndpoint())
.split().method(xmlSplitter, "splitMessage").streaming().process(xmlProcessor).choice();
for (RouteConfig filter : filters) {
choice = choice.when(header(REPORT_TYPE_HEADER_NAME).contains(filter.getReportTypeHeaderFilter()))
.to(filter.getToEndpoint());
}
choice.otherwise().to(routeConfig.getErrorEndpoint());
But the routing is not happening at all, All messages are sent to the errorEndpoint.
I found the reason to be the splitter deleting the header, as its ahead of the routing.
It seems I cannot use splitting after routing.
What is the solution to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
split() 不应删除标头...您确定您的 xmlSplitter/xmlProcessor 不会引起问题吗?
这是一个简单的示例,显示标头被保留......
split() shouldn't remove the headers...are you sure your xmlSplitter/xmlProcessor aren't causing issues?
here is a simple example to show that the headers are preserved...