activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Asif_A <>
Subject RedeliveryPolicy appears to get ignored in an XA Transaction
Date Tue, 29 May 2007 11:14:14 GMT

I have an application which takes part in a XA Transaction. The application

1) Dequeue message
2) Process message
3) Persist message to database.

All of these steps work fine. The problem is at step 2 I am throwing a
runtime exception to test message rollback. Upon throwing the exception, I
clearly see that the transaction has rolled back and that nothing has been
persisted. The only problem is once the message is put back onto the queue
it should stop trying to resend the message after 3 attempts. 

So far it has got up to 453 retries and still continues. From what I can see
it is ignoring my ReDelivery policy which I have set up.

I can make the application work by manually checking the “redelivery
counter” property on the message and stopping processing if this value
exceeds 3 but would prefer to get the listener to do this for me.

My context file is as so

	<bean id="jotm"
		class="org.springframework.transaction.jta.JotmFactoryBean" />

	<bean id="jotmTransactionManager"
		<property name="userTransaction" ref="jotm" />

	<bean id="jmsFactory2"
		<property name="brokerURL" value="tcp://localhost:61616" />
		<property name="redeliveryPolicy">
		<bean class="org.apache.activemq.RedeliveryPolicy">
			<property name="initialRedeliveryDelay" value="600" />
			<property name="maximumRedeliveries" value="3" />

	<bean id="jmsConnectionFactory2"
		<property name="connectionFactory" ref="jmsFactory2" />
		<property name="jtaTransactionManager"
			ref="jotmTransactionManager" />

	<bean id="destination"
		<constructor-arg value="defaultQueue" />

	<bean id="listenerContainer"
		<property name="concurrentConsumers" value="5" />
		<property name="connectionFactory" ref="jmsConnectionFactory2" />
		<property name="destination" ref="destination" />
		<property name="messageListener" ref="myMessageProcessor" />
		<!--<property name="sessionTransacted" value="true" />
		--><property name="transactionManager"
			ref="jotmTransactionManager" /> 

	<bean id="myMessageProcessor"
		<property name="jmsTemplate">
			<bean class="org.springframework.jms.core.JmsTemplate">
				<property name="connectionFactory" ref="jmsFactory2" />
				<property name="defaultDestinationName"
					value="defaultQueue" />

	<bean id="activeMqConnectionFactory"
		<property name="brokerURL" value="tcp://localhost:61616" />

	<bean id="connectionFactory"
		<property name="targetConnectionFactory"
			ref="activeMqConnectionFactory" />

	<bean id="jmsTemplate"
		<property name="connectionFactory" ref="connectionFactory" />
		<property name="defaultDestinationName" value="defaultQueue" />
		<property name="pubSubDomain" value="false" />

	<bean id="queueSender" class="test.SampleSender">
		<property name="jmsTemplate" ref="jmsTemplate" />

The message processor

public void onMessage(Message msg)
String message="NOT_SET";
		message = ((TextMessage) msg).getText();
	} catch (JMSException e)
	System.out.println("message=" + message);
	throw new RuntimeException("ROLLBACK TEST....");

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message