2013-12-20 37 views
0

我想學習Apache駱駝路由。對於一個基本的例子,我想知道如何根據XML標籤中的值進行路由。例如,如果我們有父標籤3個XML文件:基於標記值的路由消息 - Apache Camel

<item type="n1" /> 
<item type="n2" /> 
<item type="n3" /> 

我想航線這3分爲3個不同的管道...

所以這裏是我的想法(春季):

<route id="NormalizeMessageData"> 

<from uri="jms:incomingOrders" /> 
<convertBodyTo type="java.lang.String" /> 

<choice> 
<when> 
    <simple>${body} contains '?xml'</simple> <!-- to make sure its xml file only --> 
    * 
    * 
    * 
    <unmarshal> 
    <jaxb contextPath="org.fusesource.camel" /> 
    </unmarshal> 
    <to uri="jms:orders" /> 
</when> 
</choice> 

看到星星(*),這是我們需要進行一些檢查的地方。但是如何?

+0

看一看在[XPath的組件(http://camel.apache.org/ xpath.html)。 – Ralf

回答

2

見上面鏈接的所有細節駱駝XPath文檔,但你應該只需要像:

<choice> 
    <when> 
     <xpath>/item/@type = 'n1'</xpath> 
     ... 
    </when> 
</choice> 
+0

嗯。 ' // item [@ type ='n1']''?這也會起作用嗎? –