Apache camel 是否可以在camel中创建从属路由

Apache camel 是否可以在camel中创建从属路由,apache-camel,Apache Camel,我已经创建了多个部门,员工从文件系统folderssay部门获取输入,Employee并处理这些文件 现在,我想让他们依赖。所以,如果我在这些文件夹中同时上传emp.csv和dept.csv,那么它将首先处理部门文件,一旦完成,它将开始为员工处理文件 骆驼有没有办法做到这一点 我查看了该功能,但它仅在开始路线时第一次起作用。但是,我需要在整个路线生命中都有相同的行为 谢谢 <route id="b" xmlns="http://camel.apache.org/schema/spring"

我已经创建了多个部门,员工从文件系统folderssay部门获取输入,Employee并处理这些文件

现在,我想让他们依赖。所以,如果我在这些文件夹中同时上传emp.csv和dept.csv,那么它将首先处理部门文件,一旦完成,它将开始为员工处理文件

骆驼有没有办法做到这一点

我查看了该功能,但它仅在开始路线时第一次起作用。但是,我需要在整个路线生命中都有相同的行为

谢谢

<route id="b" xmlns="http://camel.apache.org/schema/spring">
    <from uri="file:/home/dev/code/Integration/RunCamleExample/src/main/resources/csv/Department?repeatCount=1&amp;noop=true&amp;delay=10000"/>
    <log message="Department data is : ${body}"/>
</route>
<route id="employee" xmlns="http://camel.apache.org/schema/spring">
    <from uri="file:/home/dev/code/Integration/RunCamleExample/src/main/resources/csv/Employee?noop=true&amp;delay=10000"/>
    <log message="Employee data is : ${body}"/>
</route>

首先可以使用RouteContext在Camel中实现依赖路由执行

示例:如果路由“A”在路由“B”之前执行,则路由“A”应定义为“RouteContext”,而路由“B”在上下文中定义如下:

 <routeContext id="A" xmlns="http://camel.apache.org/schema/spring">
    <route id="A">
         <from uri="file:/home/dev/code/Integration/RunCamleExample/src/main/resources/csv/Department?repeatCount=1&amp;noop=true&amp;delay=10000"/>
         <log message="Department data is : ${body}"/>
    </route>
 </routeContext>
然后,应首先参考此routeContext定义常规上下文

<camelContext id="test" xmlns="http://camel.apache.org/schema/spring">
    <routeContextRef ref="A"/>
    <route id="B">
         <from uri="file:/home/dev/code/Integration/RunCamleExample/src/main/resources/csv/Employee?noop=true&amp;delay=10000"/>
         <log message="Employee data is : ${body}"/>
    </route>
</camelContext>

我建议使用其他逻辑来处理这项任务。两个简单的方法:

使用 使用PollRich在路由中间收集额外资源,例如文件系统中具有已知名称的文件 流程:从端点收集部门文件-对于文件系统中的每个部门文件->收集一次具有已知名称的单个员工文件-->执行任何其他操作(如果有) 使用 使用ControlBus组件控制仅一条处于“开始”状态的路由 流程:启动路线A-当路线A完成其目标->暂停路线A-->启动路线B-当路线B完成其目标->暂停路线B-->启动路线A[返回头部]