3

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...
}
4

2 回答 2

3

MQJMS1016 是一个内部错误,表明连接丢失是由于代码或 WMQ 本身的问题。调整频道会有所帮助,但您确实需要解决为什么应用程序以足够快的速度喷出孤立连接以耗尽所有可用频道的问题。

我想做的第一件事是检查 WMQ 的版本和正在运行的 WMQ 客户端的版本。如果这是新开发,请确保您使用的是 WMQ v7 客户端,因为 v6 已于 2011 年 9 月结束。v7 客户端与 v6 QMgrs 一起使用,直到您也能够升级它。进入 v7 客户端和 QMgr 后,您可以使用相当多的频道调整和重新连接选项。

WMQ v7 客户端下载在这里:http ://bit.ly/bXM0q3

另外,请注意,上面代码中的重新连接逻辑在尝试之间不会休眠。如果客户端以高速抛出连接请求,它可以使 WMQ 侦听器过载并执行非常有效的 DOS 攻击。建议在尝试之间睡几秒钟。

最后,请在您的 JMSException 捕获块中打印链接的异常。如果您对 JMS 传输提供程序有疑问,JMS 链接异常将包含任何低级错误信息。对于 WMQ,它包含原因代码,例如 2035 MQRC_AUTHORIZATION_ERROR 或 2033 MQRC_NO_MSG_AVAILABLE。这是一个例子:

try {
  .
  . code that might throw a JMSException
  .
} catch (JMSException je) {
  System.err.println("caught "+je);
  Exception e = je.getLinkedException();
  if (e != null) {
    System.err.println("linked exception: "+e);
  } else {
    System.err.println("No linked exception found.");
  }
}

如果您在某个晚上的凌晨 2 点收到错误,您的 WMQ 管理员将感谢您提供链接的异常。

于 2010-04-26T21:00:33.967 回答
1

由于孤立的连接(MQ 端的卡住连接)不会影响消息处理(即它们不消耗消息),所以我们保持原样,直到达到 MQ 上允许的最大连接数。

恢复不再起作用,一旦我们到达那个点,MQ 管理员必须手动清理孤立的连接,但是,好消息是搜索这个特定问题导致 IBM 支持站点上报告了一个问题:

在这里检查

于 2010-01-17T11:18:32.633 回答