简体   繁体   English

Apache 骆驼多端点

[英]Apache camel multiple endpoints

I do a sql select and save the data in CSV. Here i would like to do is sending the sql result to two endpoints.我做了一个 sql select 并将数据保存在 CSV 中。这里我想做的是将 sql 结果发送到两个端点。

I am using camel version 2.12.3我正在使用骆驼版本 2.12.3

I tried with multicast but it doesn't work for the seconde endpoint.我尝试使用多播,但它不适用于第二个端点。 I have the sql result only in first file but not the seconde我只有第一个文件有 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>

Do you have other suggestion?你有其他建议吗? Otherwise is there any possiblity to do it with groovy?否则有没有可能用 groovy 来做?

You could use a wiretap to duplicate the message and send it to the first endpoint.您可以使用窃听来复制消息并将其发送到第一个端点。 Or put the body in a property and get it after the first endpoint call.或者将正文放在属性中并在第一个端点调用后获取它。 The différence is on your error handling strategy.不同之处在于您的错误处理策略。

I found this below and it works fine for me我在下面找到了这个,对我来说很好用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM