拆分apache骆驼后恢复标头值 [英] recover headers value after split apache camel

查看:27
本文介绍了拆分apache骆驼后恢复标头值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 xml,我使用 split 标签在 Spring DSL 中进行处理.我所做的基本上是在 xml 中搜索一个值,当我找到这个值时,我需要获取另一个标签的值,同一元素的子元素并保存到标题中.这个操作看起来很简单,但是我无法在 split 之外恢复我的标题,我需要这样做.我尝试使用标题和属性,结果是一样的.

I have a xml where I'm using the split tag to process in Spring DSL. What I'm doing is basically seaching for a value in the xml, when I find this value I need to get the value of another tag, child of the same element and save to a header. This operations seems simple, but I can't recover my headers outside split and I need to. I tried with headers and properties and the result was the same.

请帮我弄清楚我做错了什么.

Please help me to figure out what I'm doing wrong.

代码示例:

<route>
...
<split>
    <xpath>//FatherTag/ChildTag</xpath>
    <to uri="direct:processingRoute"/>
</split>

</route>

<route>
<from uri="direct:processingRoute"/>
<choice>
<when>
<simple>....</simple>
    <setHeader headerName="foo">
        <constant>test</constant>
    </setHeader>
</when>
</choice>

</route>

推荐答案

您需要定义一个 AggregationStrategy.来自 Camel Splitter:

You need to define an AggregationStrategy. From Camel Splitter:

拆分器返回的内容

Camel 2.3 及更新版本:

默认情况下,拆分器将返回原始输入消息.

The Splitter will by default return the original input message.

适用于所有版本

您可以通过将您自己的策略作为 AggregationStrategy 提供来覆盖它.

You can override this by suppling your own strategy as an AggregationStrategy.

您的 AggregationStrategy 需要检查每个子标记的适当标头集,并将其传递到拆分操作的结果 Exchange 输出消息上.

Your AggregationStrategy needs to check the appropriate header set for each child tag and pass it on the resulting Exchange output message for the split operation.

这篇关于拆分apache骆驼后恢复标头值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆