2012-05-07 54 views
2

我們正在嘗試使用Mule ESB和JBoss Messaging來構建簡單的事務性jms-to-jms路由器。當我們使用配置如下的應用程序運行Mule ESB時,我們會觀察到奇怪的行爲。將消息從一個jms隊列路由到另一個隊列時的事務提交延遲

  1. 大約10個消息從隊列TEST1路由到TEST2
  2. 什麼也沒有發生爲〜40秒。當我們開始測試
  3. 轉到1

隊列TEST1填充有大約500的消息。我們使用Mule 3.2和JBoss 5.1。

如果我從下面的代碼中刪除交易一切正常,所有消息立即發送到隊列test2。另外,如果我將事務從xa更改爲jms,則一切都很好 - 通過用jms:transaction替換xa-transaction標記。

我不知道是什麼導致ESB上的消息處理暫停,可能是事務提交延遲。

我的問題是:我應該怎麼做xa事務正常工作?

如果需要,我會提供更多細節。我問在騾子ESB論壇這個問題沒有答案http://forum.mulesoft.org/mulesoft/topics/transaction_commit_delay_when_routing_message_from_one_jms_queue_to_another

<?xml version="1.0" encoding="UTF-8"?> 
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jbossts="http://www.mulesoft.org/schema/mule/jbossts" version="CE-3.2.1" xsi:schemaLocation=" 
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/jbossts http://www.mulesoft.org/schema/mule/jbossts/current/mule-jbossts.xsd "> 
    <jbossts:transaction-manager> </jbossts:transaction-manager> 
    <configuration> 
     <default-threading-profile maxThreadsActive="30" maxThreadsIdle="5"/> 
     <default-receiver-threading-profile maxThreadsActive="10" maxThreadsIdle="5"/> 
    </configuration> 
    <spring:beans> 
     <spring:bean id="jmsJndiTemplate" class="org.springframework.jndi.JndiTemplate" doc:name="Bean"> 
      <spring:property name="environment"> 
       <spring:props> 
        <spring:prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</spring:prop> 
        <spring:prop key="jnp.disableDiscovery">true</spring:prop> 
        <spring:prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</spring:prop> 
        <spring:prop key="java.naming.provider.url">localhost:1099</spring:prop> 
       </spring:props> 
      </spring:property> 
     </spring:bean> 
     <spring:bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" doc:name="Bean"> 
      <spring:property name="jndiTemplate"> 
       <spring:ref bean="jmsJndiTemplate"/> 
      </spring:property> 
      <spring:property name="jndiName"> 
       <spring:value>XAConnectionFactory</spring:value> 
      </spring:property> 
     </spring:bean> 
    </spring:beans> 
    <jms:connector name="JMS" specification="1.1" numberOfConsumers="10" connectionFactory-ref="jmsConnectionFactory" doc:name="JMS"/> 
    <flow name="flow" doc:name="flow"> 
     <jms:inbound-endpoint queue="test1" connector-ref="JMS" doc:name="qt1"> 
      <xa-transaction action="ALWAYS_BEGIN"/> 
     </jms:inbound-endpoint> 
     <echo-component doc:name="Echo"/> 
     <jms:outbound-endpoint queue="test2" connector-ref="JMS" doc:name="qt2"> 
      <xa-transaction action="ALWAYS_JOIN"/> 
     </jms:outbound-endpoint> 
     <echo-component doc:name="Echo"/> 
    </flow> 
</mule> 

Here之前,你可以找到記錄片段1個消息交互。請注意,在這種情況下,沒有任何延遲。 和here是11條消息的日誌片段。他們都在應用程序啓動時排隊測試1,因爲您可以看到10條消息立即路由並且一條延遲了1分鐘。

+0

在延遲之後交易是正確提交還是回滾?您可以將Mule日誌級別設置爲DEBUG,並共享* 1 *消息交互的日誌條目(即將一條消息放入'test1'隊列中)? –

+0

延遲交易被正確提交,消息出現在隊列test2中。我添加了日誌來質疑顯示1和11消息的交互。 –

回答

1

我發現我的問題的根源:我的隊列用下列屬性定義:

<attribute name="RedeliveryDelay">60000</attribute> 

刪除或設定用低值解決我的問題與延遲。問題是,我不知道爲什麼:)

我一直認爲傳遞失敗時會使用重新傳遞延遲,但在我的應用程序中並非如此。

+0

你發現它爲什麼會發生? – androdevo

+0

不幸的是,沒有。 –

相關問題