2012-10-17 104 views
2

我從隊列中路由消息 - >使用xslt轉換它並將其轉發到另一個隊列日誌。駱駝XSLT消息路由問題

我的駱駝配置如下:

<camelContext xmlns="http://camel.apache.org/schema/spring" 
    streamCache="true"> 
    <route> 
     <from uri="jms:queue:TradeEventsToESBQueue" /> 
     <multicast> 
      <to uri="xslt:com/tpt/esb/tradeevent/confirmation.xsl" /> 
      <to uri="xslt:com/tpt/esb/tradeevent/valuation.xsl" /> 
     </multicast> 
    </route> 

    <route> 
     <from uri="xslt:com/tpt/esb/tradeevent/confirmation.xsl" /> 
     <to uri="log:output?showAll=true" /> 
    </route> 

    <route> 
     <from uri="xslt:com/tpt/esb/tradeevent/valuation.xsl" /> 
     <to uri="jms:queue:TradeValuationStartQueue1?jmsMessageType=Text" /> 
     <to uri="log:output?showAll=true" /> 
    </route> 
</camelContext> 

在運行該程序,我收到以下錯誤:

Caused by: org.apache.camel.ExpectedBodyTypeException: Could not extract IN message body as type: interface javax.xml.transform.Source body is: null at org.apache.camel.builder.xml.XsltBuilder.getSource(XsltBuilder.java:482)[64:org.apache.camel.camel-core:2.10.1] at org.apache.camel.builder.xml.XsltBuilder.process(XsltBuilder.java:125)[64:org.apache.camel.camel-core:2.10.1] at org.apache.camel.impl.ProcessorPollingConsumer.receive(ProcessorPollingConsumer.java:58)[64:org.apache.camel.camel-core:2.10.1]

任何想法是什麼原因造成這個問題?

回答

2

您不應該以這種方式使用XSLT組件。

您應該特別不要嘗試在XSLT中使用「from」,而是將其與任何內部傳輸組件(直接用於該實例)結合使用。我認爲以下將做你想要的。

<route> 
    <from uri="jms:queue:TradeEventsToESBQueue" /> 
    <multicast> 
     <to uri="direct:confirmation"/> 
     <to uri="direct:valuation"/> 
    </multicast> 
</route> 

<route> 
    <from uri="direct:confirmation"/> 
    <to uri="xslt:com/tpt/esb/tradeevent/confirmation.xsl" /> 
    <to uri="log:output?showAll=true" /> 
</route> 

<route> 
    <from uri="direct:valuation"/> 
    <to uri="xslt:com/tpt/esb/tradeevent/valuation.xsl" /> 
    <to uri="jms:queue:TradeValuationStartQueue1?jmsMessageType=Text" /> 
    <to uri="log:output?showAll=true" /> 
</route> 
+0

非常感謝,這工作。 – ABose