2013-10-04 51 views
0

我正在使用Apache Camel 2.11.1。看來,這兩個XML定義是不等價的駱駝:如何在Apache Camel中以JMS組件的格式定義ActiveMQ組件

第一個定義:

<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> 

第二個組件定義在執行過程中會導致掛起。

回答

0

似乎很適合我。我必須用創建的原型覆蓋Spring版本。但我用這個,它工作得很好。

請在這裏找到我的示例項目:當您使用INOUT模式 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" /> 

+0

的問題提出。 – sancho21

相關問題