【问题标题】:Apache camel multiple endpointsApache骆驼多个端点
【发布时间】:2020-09-02 14:40:11
【问题描述】:

我执行 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 做到这一点?

【问题讨论】:

  • 如果您不需要并行导出,也可以完全删除多播。

标签: xml groovy apache-camel spring-camel


【解决方案1】:

您可以使用窃听器复制消息并将其发送到第一个端点。 或者将主体放在一个属性中,并在第一个端点调用之后获取它。 不同之处在于您的错误处理策略。

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-04
      • 1970-01-01
      • 1970-01-01
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多