首页 > 解决方案 > Apache骆驼多个端点

问题描述

我做了一个 sql 选择并将数据保存在 CSV 中。在这里,我想做的是将 sql 结果发送到两个端点。

我正在使用骆驼版本 2.12.3

我尝试了多播,但它不适用于第二个端点。我只有第一个文件中的 sql 结果,而不是第二个文件

<to uri="sql:{{export.select.query}}?dataSource=selectDataSource" />
    <marshal>
        <csv autogenColumns="true" delimiter="|" />
    </marshal>
        <multicast stopOnException="true">
            <to uri="file:{{export.select.dir}}?fileName=${property.exportSelectFileName}_exportSelect.csv&amp;charset=utf-8" />
            <to uri="file:{{export.select_2.dir}}?fileName=exportSelect_${property.exportSelectFileName}.csv&amp;charset=utf-8&amp;fileExist=Append" />
        
    </multicast>

你有其他建议吗?否则有没有可能用 groovy 来做呢?

标签: xmlgroovyapache-camelspring-camel

解决方案


我在下面找到了它,它对我来说很好用

<recipientList>
     <constant>file:{{export.select.dir}}?fileName=${property.exportSelectFileName}_exportSelect.csv&amp;charset=utf-8,file:{{export.select_2.dir}}?fileName=exportSelect_${property.exportSelectFileName}.csv&amp;charset=utf-8&amp;fileExist=Append </constant>
</recipientList>

推荐阅读