Jan 4th, 2010, 10:25 AM
MessageChannelPartitionHandler, basic jms question
It's been a while since I've played with messaging in Java, so forgive me
I want multiple subscribers (remote instances) to process messages. Each message should only be processed one time, so it's not a JMS topic.
Can I have multiple subscribers on a single JMS queue, or do I need to create a new JSM queue for each subscriber?
Jan 4th, 2010, 11:29 AM
Queue consumers are not called "subscribers". There is nothing to stop you using a single queue from multiple consumers - that's usually known as the Competing Consumers Pattern.
Jan 4th, 2010, 01:35 PM
Awesome, exactly what I was looking for.
Competing Consumers Pattern.
Jan 5th, 2010, 09:10 AM
Can I use the Competing Consumers Pattern to solve the problem below?
I use DefaultMessageListenerContainer defines a listener to pick up messages in a queue and process them.
The issue I need to solve is that when a service used to process the messages is down I want to put the messages back to the queue and to be processed later, say in 10 minutes.
How to set the 10 minutes to the messages when put them back to the queue so the listener will not pick them up or filter them out in the next 10 minutes?
Is there a way to filter the message in jms queue by a dynamically generated timestamp?
Jan 5th, 2010, 10:31 AM
If a service used to process the messages is down, then how would the messages be moved off the queue in the first place?
I would design your system so that the process that is processing the message is the same that is pulling it off the queue.
Jan 5th, 2010, 10:45 AM
Sorry it was not made clear.
The listener to process the messages in a jms queue is not down but a service the listener calls as a part of the process is down. When that happens the listener gets the message but can not complete the process so put it back to the queue. The service may be brought up in 10 minutes. At that time the message can be processed.
Jan 5th, 2010, 11:57 AM
There is a Retry handling that I think it work for you. Do a search for Retry in the spring batch documentation.
Jan 12th, 2010, 11:07 AM
Basically I used org.apache.activemq.ActiveMQConnectionFactory so configue a redeliveryPolicy for it. It defines initialRedeliveryDelay that can be set to 10 minutes.