You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by kaipa <al...@mtu-net.ru> on 2006/09/15 11:38:48 UTC

Redelivery of failed messages

Hi all,

We are implementing a fail-over scenario for message processing in the
queue. We may have one to many message producers and one to many phisically
separated servers that consume messages from the queue. It is possible that
one consuming server fails for some reason and we need to redeliver message
to the different server in this case. Here is the sequence we want to
implement:

1. Message is posted to the queue
2. Message is consumed by server1
3. Server1 one fails to process the message for some reason. 
4. Message is re-delivered to server2.

Note, server1 does not brake the connection, it just can't process one
particular message.

We use AMQ 4.0.1 with Spring 2.0 and consume message with Spring listener.
Here is the typical configuration:

  <bean id="connectionFactory"
      class="org.apache.activemq.ActiveMQConnectionFactory">
     <property name="brokerURL" value="tcp://qservice:61616" />
     <property name="redeliveryPolicy">
     	  <bean class="org.apache.activemq.RedeliveryPolicy">
	  	  		<property name = "initialRedeliveryDelay" value="60000"/>
			 	<property name = "backOffMultiplier" value="2"/>
				<property name = "useExponentialBackOff" value="true"/>
				<property name = "maximumRedeliveries" value="3"/>
  		  </bean>     	
     </property>
   </bean>

    <bean id="listenerContainer"
     
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="concurrentConsumers" value="1" />
        <property name="connectionFactory" ref="connectionFactory" />
        <property name="destination" ref="destination" />
        <property name="messageListener" ref="messageListener" />
    </bean>

MessageListener throws an exception in onMessage() if it can't process the
message. However, we can not make re-delivery to work. It is not being
re-delivered yet to the same server!

Could you help us to understand:
1. What is wrong in our case?
2. How to implement re-delivery as desired.
3. I've tried some tests, and re-delivery works if transactional session is
used and rollback() called. But how to make it working with message
listeners?

Thank you in advance.
-- 
View this message in context: http://www.nabble.com/Redelivery-of-failed-messages-tf2276524.html#a6322201
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Redelivery of failed messages

Posted by James Strachan <ja...@gmail.com>.
On 9/15/06, Aleksey <al...@webamg.com> wrote:
>
>
> James.Strachan wrote:
> >
> > Yes. Rolling back a transaction will redelivery the message. Also
> >
>
> Question is : will Active MQ redeliver to the same consumer or message will
> be re-delivered by broker to another consumers/on other servers?

We try to redeliver to the same consumer first - since this is least
likely to break ordering of queues. Then only if that consumer reaches
the redelivery counter (or terminates) do we try another consumer.


> For us this important because we want to build fault tolerant message
> delivery to multiple servers from one queue.
> Is it feasible/correct to do this way?

Yes

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Redelivery of failed messages

Posted by Aleksey <al...@webamg.com>.

James.Strachan wrote:
> 
> Yes. Rolling back a transaction will redelivery the message. Also
> 

Question is : will Active MQ redeliver to the same consumer or message will
be re-delivered by broker to another consumers/on other servers?
As JMS spec does not specify __how__ message be re-delivered, it depends
ActiveMQ implementation.

For us this important because we want to build fault tolerant message
delivery to multiple servers from one queue.
Is it feasible/correct to do this way?

-- 
View this message in context: http://www.nabble.com/Redelivery-of-failed-messages-tf2276524.html#a6331847
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Redelivery of failed messages

Posted by James Strachan <ja...@gmail.com>.
On 9/15/06, Aleksey <al...@webamg.com> wrote:
>
> James,
>
> spring is just one side of question.
> How spring handles session.rollback() ?

I've no idea - best look at the spring code. I can only really talk
about ActiveMQ

>  If we will thought excfeption and it
> is handled as rollback of transaction, will it mean that this message has
> chance to be delivered to another server?

Yes. Rolling back a transaction will redelivery the message. Also
closing a consumer without acknowledging a message (in client-ack
mode) will do the same
-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Redelivery of failed messages

Posted by Aleksey <al...@webamg.com>.
James,

spring is just one side of question.
How spring handles session.rollback() ? If we will thought excfeption and it
is handled as rollback of transaction, will it mean that this message has
chance to be delivered to another server?
This is important because primary reason in our case is fault tolerance

Aleksey



It might be worth asking the Spring folks what
DefaultMessageListenerContainer does in terms of transactions &
acknowledgements as I've no idea. I think I saw some post on the
spring forum that things don't work correctly with that container and
you have to use the SimpleMessageContainer or something.

On 9/15/06, kaipa <al...@mtu-net.ru> wrote:
>
> Hi all,
>
> We are implementing a fail-over scenario for message processing in the
> queue. We may have one to many message producers and one to many
> phisically
> separated servers that consume messages from the queue. It is possible
> that
> one consuming server fails for some reason and we need to redeliver
> message

-- 
View this message in context: http://www.nabble.com/Redelivery-of-failed-messages-tf2276524.html#a6323532
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Redelivery of failed messages

Posted by James Strachan <ja...@gmail.com>.
It might be worth asking the Spring folks what
DefaultMessageListenerContainer does in terms of transactions &
acknowledgements as I've no idea. I think I saw some post on the
spring forum that things don't work correctly with that container and
you have to use the SimpleMessageContainer or something.

On 9/15/06, kaipa <al...@mtu-net.ru> wrote:
>
> Hi all,
>
> We are implementing a fail-over scenario for message processing in the
> queue. We may have one to many message producers and one to many phisically
> separated servers that consume messages from the queue. It is possible that
> one consuming server fails for some reason and we need to redeliver message
> to the different server in this case. Here is the sequence we want to
> implement:
>
> 1. Message is posted to the queue
> 2. Message is consumed by server1
> 3. Server1 one fails to process the message for some reason.
> 4. Message is re-delivered to server2.
>
> Note, server1 does not brake the connection, it just can't process one
> particular message.
>
> We use AMQ 4.0.1 with Spring 2.0 and consume message with Spring listener.
> Here is the typical configuration:
>
>   <bean id="connectionFactory"
>       class="org.apache.activemq.ActiveMQConnectionFactory">
>      <property name="brokerURL" value="tcp://qservice:61616" />
>      <property name="redeliveryPolicy">
>           <bean class="org.apache.activemq.RedeliveryPolicy">
>                                 <property name = "initialRedeliveryDelay" value="60000"/>
>                                 <property name = "backOffMultiplier" value="2"/>
>                                 <property name = "useExponentialBackOff" value="true"/>
>                                 <property name = "maximumRedeliveries" value="3"/>
>                   </bean>
>      </property>
>    </bean>
>
>     <bean id="listenerContainer"
>
> class="org.springframework.jms.listener.DefaultMessageListenerContainer">
>         <property name="concurrentConsumers" value="1" />
>         <property name="connectionFactory" ref="connectionFactory" />
>         <property name="destination" ref="destination" />
>         <property name="messageListener" ref="messageListener" />
>     </bean>
>
> MessageListener throws an exception in onMessage() if it can't process the
> message. However, we can not make re-delivery to work. It is not being
> re-delivered yet to the same server!
>
> Could you help us to understand:
> 1. What is wrong in our case?
> 2. How to implement re-delivery as desired.
> 3. I've tried some tests, and re-delivery works if transactional session is
> used and rollback() called. But how to make it working with message
> listeners?
>
> Thank you in advance.
> --
> View this message in context: http://www.nabble.com/Redelivery-of-failed-messages-tf2276524.html#a6322201
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/