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 7651783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:35:30+00:00 2026-05-31T11:35:30+00:00

I have got a Spring MDP implemented using Spring DefaultMessageListenderContainer listening to an input

  • 0

I have got a Spring MDP implemented using Spring DefaultMessageListenderContainer listening to an input queue on WebSphere MQ v7.1. If there is a bad message coming in (that causes RuntimeException), what currently happens is that, the transaction is rolled back, and the message is put back into the queue. However the MDP goes into an infinite loop.

Question 1: For my requirements I would like to be able to shut down the processing the moment it sees a bad message. No retries needed. Is it possible to shutdown the message listener gracefully in case it sees a bad message (as opposed to crude System.exit() or methods of that sort)? I definitely don’t like it to go into an infinite loop.

Edit:

Question 2: Is there a way to stop or suspend the listener container to stop further processing of 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. Editorial Team
    Editorial Team
    2026-05-31T11:35:32+00:00Added an answer on May 31, 2026 at 11:35 am

    I solved the problem in the following manner, not sure if this is the best way, however it works.

    1. MDP Implements ApplicationContextAware; I also maintain a listener state (enum with OPEN, CLOSE, ERROR values) MDP Code fragment below:
    //context
    private ConfigurableApplicationContext applicationContext;
    
    //listener state
    private ListenerState listenerState = ListenerState.OPEN;
    
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
      this.applicationContext = (ConfigurableApplicationContext) applicationContext;
    }
    //onMessage method
    public void processMessages(....) {
      try {
        process(...);
      } catch (Throwable t) {
        listenerState = ListenerState.ERROR;           
        throw new RuntimeException(...);            
      }    
    }
    
    @Override
    public void stopContext() {        
      applicationContext.stop();  
    }
    
    1. In the java main that loads the spring context i do this:
        //check for errors for exit
        Listener listener = (Listener)context.getBean("listener");
        listenerContainer listenerContainer =
                (ListenerContainer)context.getBean("listenerContainer");
    
        try {
            while(true) {
                Thread.sleep(1000); //sleep for 1 sec
                if(!listener.getListenerState().equals(ListenerState.OPEN)) {
                    listener.stopContext();
                    listenerContainer.stop();
                    System.exit(1);
                }>             }            
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a JAX-WS WebService that is using Spring 3 IOC. I have coded
I have got a simple project using spring. In the spring config, I have
has any one using Spring MVC with Jquery! i have got a strange problem
I'm using spring and freemarker and have the basics working. I've got a properties
I have looked at Spring MVC a few times briefly, and got the basic
Have got an NSString *str = @12345.6789 and want to find out if there
When i run my spring junit test i got this error message : Caused
I'm using spring with JPA. And I've got two EntityManagers that contain different entities
I am using spring, spring security, hibernate. Got a jsp page where i am
I've got a spring roo project and I would like to have the ability

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.