简体   繁体   English

Apache Camel路由

[英]Apache Camel routing

A short question about Apache Camel. 关于Apache Camel的简短问题。 I have the following scenario, where my server receives jms messages and then transform to csv file and then insert DB. 我有以下情形,其中我的服务器接收jms消息,然后转换为csv文件,然后插入DB。 For this purpose i have 2 beans: 为此,我有2个bean:

  • xml2csv xml2csv
  • insertDB insertDB

I use routing like: 我使用像这样的路由:

    <route id="route1" errorHandlerRef="myErrorHandler">
        <from uri="file://{someFolder1}}
            ?...
        <to uri="bean:xml2csv" />
        <log message="transformed to xml file" />
    </route>

    <route id="route2" errorHandlerRef="myErrorHandler">
        <from uri="file://{{someFolder2}}
            ?...
        <to uri="direct:csvOnboardingChannel" />
    </route>

    <route id="csvOnboarding" errorHandlerRef="myErrorHandler">
        <from uri="direct:csvOnboardingChannel" />
        <to uri="bean:insertDB" />
    </route>

When "route" a file from-to, is it move like a message? 从头到尾“路由”文件时,它像消息一样移动吗? or putting the question different, does Apache Camel take a file, wrap it as a message and route it to a bean or a component? 还是换个问题,Apache Camel是否要获取文件,将其包装为消息并将其路由到Bean或组件?

Do I understand it correct or am in a wrong directation. 我是否理解它正确或方向错误。

Yes, your understanding is correct. 是的,您的理解是正确的。 Camel reads in the file's data and sends it as a message through the route to a bean. 骆驼读取文件的数据,并将其作为消息通过路由发送到Bean。 Might also be simpler as a single route, like so: 作为一条路线也可能会更简单,例如:

<route id="route1" errorHandlerRef="myErrorHandler">
    <from uri="file://{someFolder1}}">
        <to uri="bean:xml2csv" />
        <to uri="bean:insertDB" />
</route>

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

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