camel框架是一个成熟的流程框架,一般而言我们只是把它应用到一个完整的流程中,而一些逻辑的分支也是在“一个”流程中去控制的。现在如果在流程的源头就需要分支,即拿到源数据,
但是我们需要走不同的流程。(这里不再局限在“一个”流程了!),是否可行呢?下面来探讨。
首先,建立流程的配置:
context-route.xml配置文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:drools="http://drools.org/schema/drools-spring" xmlns:camel="http://camel.apache.org/schema/spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://drools.org/schema/drools-spring http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <bean id="fileConverter" class="com.kayak.itmon.web.demo.camel.FileConvertProcessor" /> <bean id="fileConverter2" class="com.kayak.itmon.web.demo.camel.FileConvertProcessor2" /> <bean id="fileConverter3" class="com.kayak.itmon.web.demo.camel.FileConvertProcessor3" /> <camelContext id="camel" autoStartup="true" xmlns="http://camel.apache.org/schema/spring"> <template id="producerTemplate" /> <threadPool id="pool" threadName="Thread-dataformat" poolSize="50" maxPoolSize="200" maxQueueSize="250" rejectedPolicy="CallerRuns" /> <route> <from uri="direct://AstartData"/> <process ref="A1"/> <to uri="direct://startA" /> </route> <route> <from uri="direct://startA"/> <threads executorServiceRef="pool"> <process ref="A2" /> </threads> </route> <!-- B流程 --> <route> <from uri="direct://BstartData"/> <process ref="B1"/> <to uri="direct://startB" /> </route> <route> <from uri=