2014-11-24 125 views
0

我正在使用JBoss Fuse 6.1.0 with Camel 2.10.0.redhat-60024。 路線列表是已知的。例如:#start, #step1, #step2, #step3, #finishApache Camel:再次呼叫路由或動態路由

但我不知道序列。或者有時候可能不需要某些路線。我只知道在#router路線(請參見下面的代碼)。

例如:#start, #step2, #step1, #step3, #finish.#start, #step1, #step3, #finish.或等

駱駝2.10.0沒有這樣的東西作爲dynamicRouter。我決定做這樣的事情:

<?xml version="1.0" encoding="UTF-8"?> 
... 
<camelContext id="blueprintContext" trace="true" 
    xmlns="http://camel.apache.org/schema/blueprint"> 
    <route id="start"> 
     <from uri="..." /> 
     <to uri="vm:router" /> 
    </route> 
    <route id="router"> 
     <from uri="vm:router" /> 
     <bean ref="stepGenerator" method="nextStep" /> 
     <choice> 
      <when> 
       <simple>${header.step} contains 'step1'</simple> 
       <to uri="vm:step1" /> 
      </when> 
      <when> 
       <simple>${header.step} contains 'step2'</simple> 
       <to uri="vm:step2" /> 
      </when> 
      <when> 
       <simple>${header.step} contains 'step3'</simple> 
       <to uri="vm:step3" /> 
      </when> 
      <when> 
       <simple>${header.step} contains 'finish'</simple> 
       <to uri="vm:finish" /> 
      </when> 
     </choice> 
    </route> 
    <route id="step1"> 
     <from uri="vm:step1" /> 
     <log message="Step 1 started." /> 
     <!-- Some logic --> 
     <to uri="vm:router" /> 
    </route> 
    <route id="step2"> 
     <from uri="vm:step2" /> 
     <log message="Step 2 started." /> 
     <!-- Some logic --> 
     <to uri="vm:router" /> 
    </route> 
    <route id="step3"> 
     <from uri="vm:step3" /> 
     <log message="Step 3 started." /> 
     <!-- Some logic --> 
     <to uri="vm:router" /> 
    </route> 
    <route id="finish"> 
     <from uri="vm:finish" /> 
     <log message="Finished!" /> 
    </route> 
</camelContext> 

假設我們有一個順序:#start, #step1, #step2, #step3, #finish。如果您嘗試運行,則會停止在#start -> #router-> #step1

#step1<to uri="vm:router" />無法正常工作。如果您撥打兩次電話,則無法使用。爲什麼? 我該如何解決這種情況駱駝2.10.0

回答

0

根據the camel website動態路由模式在 版本2.5中引入。我相信這會爲你工作...

+0

哦。我在藍圖中有一箇舊的XSD模式,告訴我關於不存在的'動態路由'標記。感謝您的警惕! – 2014-11-24 18:24:31