Announcement Announcement Module
No announcement yet.
MessageChannelPartitionHandler, basic jms question Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

    Thank you,

  • #2
    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.


    • #3
      Awesome, exactly what I was looking for.
      Competing Consumers Pattern.


      • #4
        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?


        • #5
          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.


          • #6
            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.


            • #7
              There is a Retry handling that I think it work for you. Do a search for Retry in the spring batch documentation.


              • #8
                It's solved.

                Basically I used org.apache.activemq.ActiveMQConnectionFactory so configue a redeliveryPolicy for it. It defines initialRedeliveryDelay that can be set to 10 minutes.