简体   繁体   中英

How to Stop Message Queue Service

I have wriiten startMQ method to process message from websphere message queue. Below is my code snippet.

void startMQ(){

    try { 
        // getting connection
        // getting session
        // getting queue

        for(; ;){
            // Processing every messages from queue
        }
    } catch (Exception e){

    } finally {
        // closing queue
        // closing session
        // closing connection
    }
}

public static void main(String arg[]){
    Listener l = new Listener();
    l.startMQ();    
}

From bat file i will call main method to start message queue.

if i want to stop this. How to acheive this. i thought in many ways but cannot able to implement it. Please help.

After the queue is empty, the program will get an exception with RC=2033 which means "No Message Available." As it falls out of the Catch block and into the Finally block it should hit the close queue, close session, close connection. That should do it, yeah? You may be over-thinking this one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM