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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:45:54+00:00 2026-05-24T06:45:54+00:00

I have a JMS listener app, and the class QueueReceive implements MessageListener.the main function

  • 0

I have a JMS listener app, and the class QueueReceive implements MessageListener.the main function as below:

public static void main(String[] args) throws Exception {

    InitialContext ic = getInitialContext();
    QueueReceive qr = new QueueReceive();
    qr.init(ic, QUEUE);

    System.out.println("JMS Ready To Receive Messages (
         To quit, send a \"quit\" message).");    
    // Wait until a "quit" message has been received.

    synchronized(qr) {
        while (! qr.quit) {
           try {
              qr.wait();
           } catch (InterruptedException ie) {}
           }
        }
        qr.close();
    }

Is there any way to quit the app at a specific time within the program not by way of the jms Message?

  • 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-24T06:45:56+00:00Added an answer on May 24, 2026 at 6:45 am

    You can use TimerTask [Sample Code] for this purpose.

    Example:

    import java.util.Date;
    import java.util.Timer;
    import java.util.TimerTask;
    
    public class ExitOn {
    Timer timer = new Timer();
    TimerTask exitApp = new TimerTask() {
        @Override
        public void run() {
            System.exit(0);
        }
    };
    public ExitOn() {
    timer.schedule(exitApp, new Date(System.currentTimeMillis()+5*1000));//Exits after 5sec of starting the app
    while(true)
        System.out.println("hello");
    }
    
    public static void main(String[] args) {
        new ExitOn();
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that after it does some stuff, sends a JMS message.
I have a java class Processor that is listening to a jms topic and
I have a problem with MantaRay JMS: I use a static world map because
I have a Spring JMS listener that receives a BytesMessage/JMSBytesMessage. I want to convert
I am new JMS arena, I have created multiple message listeners but one listener
I have a JMS Message Listener under JBoss 5.1, configured by Spring. Although the
I have a DefaultMessageListenerContainer setup with the following configuration: threadServiceListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) { maxConcurrentConsumers = 10
I have a stand-alone JMS app that subscribes to several different JMS topics. Each
I have used JMS in the past to build application and it works great.
I have problem with Oracle 9.2 and JMS. I created PL/SQL routine to send

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.