2

我们正在尝试使用 Mule ESB 和 JBoss Messaging 构建简单的事务处理 jms-to-jms 路由器。当我们使用如下配置的应用程序运行 Mule ESB 时,我们观察到奇怪的行为。

  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 事务正常工作?

如果需要,我会提供更多细节。我之前在 Mule 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>

在这里您可以找到 1 条消息交互的日志片段。请注意,在这种情况下没有延迟。这是 11 条消息的日志片段当应用程序启动时,它们都在队列 test1 中,你可以看到 10 条消息被立即路由,一条延迟了 1 分钟。

4

1 回答 1

1

我找到了问题的根源:我的队列是用以下属性定义的:

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

删除它或设置低值可以解决我的延迟问题。问题是,我不知道为什么:)

我一直认为在交付失败时会使用重新交付延迟,但在我的应用程序中并非如此。

于 2012-05-08T13:54:43.030 回答