0

我正在使用 Apache Camel 2.11.1。似乎这两个 xml 定义在 Camel 中并不等效:

第一个定义:

<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent"
    p:brokerURL="tcp://localhost:61616" p:transacted="true"
    p:cacheLevelName="CACHE_CONSUMER" p:concurrentConsumers="20"
    p:maxConcurrentConsumers="500" p:idleConsumerLimit="10" />

第二个定义:

<bean id="amq" class="org.apache.camel.component.jms.JmsComponent"
    p:configuration-ref="jmsConfig" p:transacted="true" p:cacheLevelName="CACHE_CONSUMER" />

<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration"
    p:connectionFactory-ref="nakedConnectionFactory"
    p:concurrentConsumers="20" p:maxConcurrentConsumers="500"
    p:idleConsumerLimit="10" />

<bean id="nakedConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
    p:brokerURL="tcp://localhost:61616" />

由于第一个定义在以下路线上运行良好,但第二个则不行。

<route>
    <from uri="amq:example.MyQueue" />
    <setHeader headerName="myRoutingSlipHeader">
        <constant>amq:one#amq:two#amq:three#amq:four</constant>
    </setHeader>
    <log message="Makan" />
    <setExchangePattern pattern="InOut" />
    <routingSlip uriDelimiter="#">
        <header>myRoutingSlipHeader</header>
    </routingSlip>
    <setExchangePattern pattern="InOnly" />
    <log message="End: ${body}" />
</route>

<route>
    <from uri="amq:one" />
    <to uri="bean:helloBean?method=stepOne" />
</route>

<route>
    <from uri="amq:two" />
    <to uri="bean:helloBean?method=stepTwo" />
</route>

<route>
    <from uri="amq:three" />
    <to uri="bean:helloBean?method=stepThree" />
</route>

<route>
    <from uri="amq:four" />
    <to uri="bean:helloBean?method=stepFour" />
</route>

第二个组件定义导致执行期间挂起。

4

1 回答 1

0

似乎对我来说工作得很好。我确实必须用创建的原型覆盖 spring 版本。但我用了这个,效果很好。

请在此处找到我的示例项目: https ://github.com/jimternet/camel-activemq

<broker xmlns="http://activemq.apache.org/schema/core" useJmx="true"
    persistent="false">
    <transportConnectors>
        <transportConnector uri="tcp://localhost:61616" />
    </transportConnectors>
</broker>

<camelContext xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="file:src/data?noop=true" />
        <to uri="activemq:personnel.records" />
    </route>
    <route>
        <from uri="activemq:personnel.records" />
        <log message="${body}" />

        <choice>
            <when>
                <xpath>/person/city = 'London'</xpath>
                <to uri="file:target/messages/uk" />
            </when>
            <otherwise>
                <to uri="file:target/messages/others" />
            </otherwise>
        </choice>
    </route>
</camelContext>


<bean id="activemq" class="org.apache.camel.component.jms.JmsComponent"
    p:configuration-ref="jmsConfig" p:transacted="true" p:cacheLevelName="CACHE_CONSUMER" />

<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration"
    p:connectionFactory-ref="nakedConnectionFactory"
    p:concurrentConsumers="20" p:maxConcurrentConsumers="500"
    p:idleConsumerLimit="10" />

<bean id="nakedConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
    p:brokerURL="tcp://localhost:61616" />

于 2013-10-09T02:28:45.857 回答