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

  • Home
  • SEARCH
  • 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 170725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:51:36+00:00 2026-05-11T12:51:36+00:00

What would be a nice and good way to temporarily disable a message listener?

  • 0

What would be a nice and good way to temporarily disable a message listener? The problem I want to solve is:

  • A JMS message is received by a message listener
  • I get an error when trying to process the message.
  • I wait for my system to get ready again to be able to process the message.
  • Until my system is ready, I don’t want any more messages, so…
  • …I want to disable the message listener.
  • My system is ready for processing again.
  • The failed message gets processed, and the JMS message gets acknowledged.
  • Enable the message listener again.

Right now, I’m using Sun App Server. I disabled the message listener by setting it to null in the MessageConsumer, and enabled it again using setMessageListener(myOldMessageListener), but after this I don’t get any more messages.

  • 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. 2026-05-11T12:51:37+00:00Added an answer on May 11, 2026 at 12:51 pm

    How about if you don’t return from the onMessage() listener method until your system is ready to process messages again? That’ll prevent JMS from delivering another message on that consumer.

    That’s the async equivalent of not calling receive() in a synchronous case.

    There’s no multi-threading for a given JMS session, so the pipeline of messages is held up until the onMessage() method returns.

    I’m not familiar with the implications of dynamically calling setMessageListener(). The javadoc says there’s undefined behavior if called ‘when messages are being consumed by an existing listener or sync consumer’. If you’re calling from within onMessage(), it sounds like you’re hitting that undefined case.

    There are start/stop methods at the Connection level, if that’s not too coarse-grained for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a good and useful code example that would be nice, short
Is there any good way to get the remaining memory available to the JVM
Can anyone tell me what would be a good way to implement soft deletes?
Would be nice if the Entity framework had the ADO.Net equivalent of DataRow.HasErrors. I'm
It would be nice if the GeoShape page included examples or the individual properties
It would be nice to use ember.js , data from git HEAD , since
I would like to present a scenario where it would be nice to: have
I'm new to mechanize in python and it would be nice if someone could
I have a ruby on rails application and it would be nice to see
Probably not. But still would be nice to have it. Kinda hard to believe

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.