2

我正在从队列中路由消息-> 使用 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>

在运行程序时,我收到以下错误:

原因:org.apache.camel.ExpectedBodyTypeException:无法将 IN 消息正文提取为类型:接口 javax.xml.transform.Source 正文为:org.apache.camel.builder.xml.XsltBuilder.getSource(XsltBuilder.java :482)[64:org.apache.camel.camel-core:2.10.1] 在 org.apache.camel.builder.xml.XsltBuilder.process(XsltBuilder.java:125)[64:org.apache.camel.骆驼核心:2.10.1] 在 org.apache.camel.impl.ProcessorPollingConsumer.receive(ProcessorPollingConsumer.java:58)[64:org.apache.camel.camel-core:2.10.1]

任何想法是什么导致了这个问题?

4

1 回答 1

2

您不应该以这种方式使用 XSLT 组件。

您尤其不应尝试将“from”与 XSLT 一起使用,而应将其与任何内部传输组件(直接用于实例)结合使用。我认为以下将做你想要的。

<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>
于 2012-10-17T08:13:51.670 回答