Websphere MQ using JMS, closed connections stuck on the MQ

Posted by Ahmad on Stack Overflow See other posts from Stack Overflow or by Ahmad
Published on 2009-09-01T19:41:35Z Indexed on 2010/04/26 21:03 UTC
Read the original article Hit count: 484

Filed under:
|
|
|

I have a simple JMS application deployed on OC4J under AIX server, in my application I'm listening to some queues and sending to other queues on a Websphere MQ deployed under AS400 server.

The problem is that my connections to these queues are terminated/closed when it stays idle for some time with the error MQJMS1016 (this is not the problem), and when that happens I attempt to recover the connection and it works, however, the old connection is stuck at the MQ and would not terminate until it is terminated manually.

The recovery code goes as follows:

public void recover() {
    cleanup();
    init();
}

public void cleanup(){
    if (session != null) {
        try {
            session .close();
        } catch (JMSException e) {
        }
    }
    if (connection != null) {
        try {
            connection.close();
        } catch (JMSException e) {
        }
    }
}

public void init(){
    // typical initialization of the connection, session and queue...
}

© Stack Overflow or respective owner

Related posts about java

Related posts about jms