Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8414177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:05:54+00:00 2026-06-10T01:05:54+00:00

I have configured Spring DefaultMessageListenerContainer as ActiveMQ consumer consuming messages from a queue. Let’s

  • 0

I have configured Spring DefaultMessageListenerContainer as ActiveMQ consumer consuming messages from a queue. Let’s call it “Test.Queue”
I have this code deployed in 4 different machines and all the machines are configured to the same ActiveMQ instance to process the messages from the same “Test.Queue” queue.

I set the max consumer size to 20 as soon as all the 4 machines are up and running, I see the number of consumers count against the queue as 80 (4 * max consumer size = 80)

Everything is fine when the messages produced and sent to the queue grows high.

When there are 1000’s of messages and among the 80 consumers, let’s say one of them is stuck it puts a freeze on Active MQ to stop sending messages to other consumers.

All messages are stuck in ActiveMQ forever.

As I have 4 machines with up to 80 consumers , I have no clue as to see which consumer failed to acknowledge.

I go stop and restart all the 4 machines and when I stop the machine that has the bad consumer which got stuck, then messages starts flowing again.

I don’t know how to configure DefaultMessageListenerContainer to abandon the bad consumer and signal ActiveMQ immediately to start sending messages.

I was able to create the scenario even without Spring as follows:

  1. I produced up to 5000 messages and sent them to the “Test.Queue” queue
  2. I created 2 consumers (Consumer A, B) and in one consumer B’s
    onMessage() method, I put the thread to sleep for a long time (
    Thread.sleep(Long.MAX_VALUE)) having the condition like when current time % 13 is 0 then put the thread to sleep.

  3. Ran these 2 consumers.

  4. Went to Active MQ and found that the queue has 2 consumers.
  5. Both A and B are processing messages
  6. At some point of time consumer B’s onMessage() gets called and it puts the Thread to sleep when the condition of current time % 13 is 0 is satisified.
  7. The consumer B is stuck and it can’t acknowledge to the broker
  8. I went back to Active MQ web console, still see the consumers as 2, but no messages are dequeued.
  9. Now I created another consumer C and ran it to consume.
  10. Only the consumer count in ActiveMQ went up to 3 from 2.
  11. But Consumer C is not consuming anything as the broker failed sending any messages holding them all as it is still waiting for consumer B to acknowledge it.
  12. Also I noticed Consumer A is not consuming anything
  13. I go and kill consumer B , now all messages are drained.

Let’s say A, B, C are managed by Spring’s DefaultMessageListenerContainer, how do I tweak Spring DefaultMessageListenerContainer to take that bad consumer off the pool (in my case consumer B) after it failed to acknowledge for X number of seconds, acknowledge the broker immediately so that the broker is not holding onto messages forever.

Thanks for your time.

Appreciate if I get a solution to this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:05:55+00:00Added an answer on June 10, 2026 at 1:05 am

    here are a few options to try…

    1. set the queue prefetch to 0 to promote better distribution across consumers and reduce ‘stuck’ messages on specific consumers. see http://activemq.apache.org/what-is-the-prefetch-limit-for.html

    2. set “?useKeepAlive=false&wireFormat.maxInactivityDuration=20000” on the connection to timeout the slow consumer after a specified inactive time

    3. set the queue policy “slowConsumerStrategy->abortSlowConsumer”…again to timeout a slow consumer

      <policyEntry ...
        ...
        <slowConsumerStrategy>
            <abortSlowConsumerStrategy />
        </slowConsumerStrategy>
        ...
      </policyEntry> 
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have configured a Spring app (using Camel for integration with an ActiveMQ broker)
I'm using a DefaultMessageListenerContainer to consume messages from a topic (Broker is ActiveMQ). Because
I have configured in following way that spring MVC app using Spring 3.1.1.RELEASE web.xml
I have configured two authentication providers in my Spring Security config: <security:authentication-manager> <security:authentication-provider ref=XProvider
I have configured the loading of the properties file as shown below (Spring 3.1)
I am using spring to initialise my beans. I have configured a bean which
I have a portlet application. It is configured using Spring framework IoC container. I
I have configured spring security with a ldap server (but continue reading, it's not
I have configured in an Spring 3 application a ContentNegotiatingViewResolver so when I invoke
I am new to Spring Security and have configured Spring Security in my Spring

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.