我尝试在多播执行我想要执行一条路由的所有路由后,使用多播来呼叫某些路由。 这是我的代码:
<?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:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:spring/beans.xml" />
<bean id="properties"
class="org.apache.camel.component.properties.PropertiesComponent">
<property name="location"
value="file:///C:\ROI\Generic\Resources\Camel\Constants.properties" />
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="activemq:queue:start.queue" />
<doTry>
<to uri="stream:out" />
<process ref="jsonProcessor" />
<to
uri="bean:validateInputIdentifiers?method=validation(${property.Source}, ${in.header.Destination})" />
<to uri="direct:contextRoute" />
<doCatch>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<log message="{{ERROR_MESSAGE}}" />
</doCatch>
</doTry>
</route>
<route>
<from uri="direct:contextRoute" />
<doTry>
<to
uri="bean:contextData?method=populateContainerInfo(${property.Source}, ${property.Destination})" />
<to uri="bean:contextManager?method=setContextData" />
<to uri="bean:contextManager?method=getContextData" />
<process ref="contextProcessor" />
<multicast>
<to
uri="seda:moveRestrictionRoute" />
<to
uri="seda:mixingRuleValidationRoute" />
</multicast>
<to uri="direct:executeMoveInventoryRoute" />
<doCatch>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<log message="{{ERROR_MESSAGE}}" />
</doCatch>
</doTry>
</route>
<route>
<from uri="seda:moveRestrictionRoute" />
<doTry>
<to
uri="bean:moveRestrictionValidation?method=validation(${property.SourceMap}, ${property.DestinationMap})" />
<doCatch>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<log message="{{ERROR_MESSAGE}}" />
</doCatch>
</doTry>
</route>
<route>
<from uri="seda:mixingRuleValidationRoute" />
<doTry>
<to
uri="bean:mixingRuleValidation?method=validation(${property.SourceMap}, ${property.DestinationMap})" />
<doCatch>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<log message="{{ERROR_MESSAGE}}" />
</doCatch>
</doTry>
</route>
<route>
<from uri="direct:executeMoveInventoryRoute" />
<doTry>
<to
uri="bean:executeMoveInventory?method=move(${property.SourceMap}, ${property.DestinationMap}, ${property.Quantity}, ${property.Item})" />
<doCatch>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<log message="{{ERROR_MESSAGE}}" />
</doCatch>
</doTry>
</route>
</camelContext>
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://localhost?broker.persistent=false" />
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
这里我遇到的问题是,在执行moveRestrictionRoute之后,它正在调用executeMoveInventory路由,并且在执行了mixedRuleVlidationRoute之后,它再次调用executeMoveInventoryRoute。
我想要的是moveRestrictionRoute和mixingRuleVlidationRoute在多播中执行,并且在执行moveRestrictionRoute和mixingRuleVlidationRoute之后只执行executeMoveInventory调用(即只有一次)。