Spring JMS消息重新传递不起作用

时间:2013-11-15 13:46:53

标签: jms activemq spring-jms

我不知道我错过了什么,当消费者无法处理消息时,它会抛出JMSException,但我看到失败的消息没有得到重新启动,否则下面的代码工作正常,请帮助我,我错过了什么?                          

                xsi:schemaLocation="http://www.springframework.org/schema/beans
                                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                                    http://www.springframework.org/schema/context
                                    http://www.springframework.org/schema/context/spring-context-3.0.xsd
                                    http://www.springframework.org/schema/beans
                                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                                    http://www.springframework.org/schema/jee
                                    http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
                                    http://www.springframework.org/schema/jms
                                    http://www.springframework.org/schema/jms/spring-jms-3.0.xsd">


            <!-- Use Springs JNDI support to look up JMS Connection Factory and Queue definitions from the
                 container. This means that specific connection details are not embedded in the application
             -->
                <bean id="mqConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
                <property name="connectionFactory">
                    <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                        <property name="brokerURL">
                            <value>vm://localhost:61616</value>
                        </property>
                         <property name="nonBlockingRedelivery" value="true"/>
                         <property name="redeliveryPolicy">
                            <bean class="org.apache.activemq.RedeliveryPolicy">
                                <property name="initialRedeliveryDelay" value="5000" />
                                <property name="backOffMultiplier" value="2" />
                                <property name="queue" value="*" />
                                <property name="useExponentialBackOff" value="true" />
                                <property name="redeliveryDelay" value="5000" />
                                <property name="maximumRedeliveries" value="20"/>
                            </bean>
                        </property>
                    </bean>
                </property>
                </bean>
                <bean id="mqProducerConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
                <property name="connectionFactory">
                    <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                        <property name="brokerURL">
                            <value>vm://localhost:61616</value>
                        </property>
                    </bean>
                </property>
                </bean>

                 <bean id="test_queue" class="org.apache.activemq.command.ActiveMQQueue"> 
                <constructor-arg value="test_queue" /> 
            </bean> 


            <bean id="testConsumer" class="com.test.jms.listener.TestConsumer">
            </bean>


            <bean id="poiMessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
                <property name="connectionFactory" ref ="mqConnectionFactory" />
                <property name="destination" ref ="test_queue"/>
                <property name="messageListener" ref ="testConsumer"/>
                <property name="concurrentConsumers" value="1" />
                <property name="sessionTransacted" value="true"/>
            </bean>


            <bean id="testProducer" class="com.test.jms.producer.testProducer">
              <property name="destination" ref="test_queue"/>
            </bean>


            <bean id="jmsTemplate"  class="org.springframework.jms.core.JmsTemplate">
                <property name="connectionFactory" ref="mqProducerConnectionFactory" />
            </bean>
          <jms:listener-container 
              container-type="default"
              connection-factory="mqConnectionFactory"
              acknowledge="transacted">
            <jms:listener destination="test_queue" ref="testConsumer" method="onMessage" />
          </jms:listener-container>
       </beans>

以上代码工作正常但不适用于邮件重新传递

0 个答案:

没有答案