recover headers value after split apache camel

主宰稳场 提交于 2019-12-11 07:58:01

问题


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.

Code sample:

<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>

回答1:


You need to define an AggregationStrategy. From Camel Splitter:

What the Splitter returns

Camel 2.3 and newer:

The Splitter will by default return the original input message.

For all versions

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

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.



来源:https://stackoverflow.com/questions/25608310/recover-headers-value-after-split-apache-camel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!