来自 Jboss 的 IBM MQ 连接泄漏
Connection leak with IBM MQ from Jboss
在我的 JavaEE 应用程序中,我通过以下方式从 IBM MQ 队列读取消息:
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class MyMessageHandler implements MessageListener {
@Resource
private MessageDrivenContext context;
@Override
public void onMessage(Message message) {
try {
processMessage(message);
}
catch (Exception e) {
context.setRollbackOnly();
}
}
应用程序部署在 Jboss EAP 6.4 上,并使用 wmq.jms.rar 适配器(实施版本:7.1.0.0-k000-L111005)。
这是来自 ejb-jar.xml:
的激活配置
<message-driven>
<display-name>MyMessageHandler</display-name>
<ejb-name>MyMessageHandler</ejb-name>
<ejb-class>org.example.MyMessageHandler</ejb-class>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>hostName</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>port</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>channel</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>queueManager</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>transportType</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>username</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>password</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>auto-acknowledge</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
当抛出异常时,回滚事务,使用IBM MQ回退机制将消息放入IBM MQ回退队列。但是,我注意到连接数量在增加,但没有释放。
这是我如何监控 IBM MQ 服务器上的连接数:
echo "display conn(*) all" | runmqsc <queue manager name> | grep <the IP of the Jboss server>| wc -l
为什么会发生?
问题似乎是由 wmq.jms.rar-适配器的版本引起的。当我们升级到更新版本 (7.5.0.9-p750-009-180830) 时,连接泄漏停止了。
在我的 JavaEE 应用程序中,我通过以下方式从 IBM MQ 队列读取消息:
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class MyMessageHandler implements MessageListener {
@Resource
private MessageDrivenContext context;
@Override
public void onMessage(Message message) {
try {
processMessage(message);
}
catch (Exception e) {
context.setRollbackOnly();
}
}
应用程序部署在 Jboss EAP 6.4 上,并使用 wmq.jms.rar 适配器(实施版本:7.1.0.0-k000-L111005)。 这是来自 ejb-jar.xml:
的激活配置<message-driven>
<display-name>MyMessageHandler</display-name>
<ejb-name>MyMessageHandler</ejb-name>
<ejb-class>org.example.MyMessageHandler</ejb-class>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>hostName</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>port</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>channel</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>queueManager</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>transportType</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>username</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>password</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>${somejbossproperty}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>auto-acknowledge</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
当抛出异常时,回滚事务,使用IBM MQ回退机制将消息放入IBM MQ回退队列。但是,我注意到连接数量在增加,但没有释放。 这是我如何监控 IBM MQ 服务器上的连接数:
echo "display conn(*) all" | runmqsc <queue manager name> | grep <the IP of the Jboss server>| wc -l
为什么会发生?
问题似乎是由 wmq.jms.rar-适配器的版本引起的。当我们升级到更新版本 (7.5.0.9-p750-009-180830) 时,连接泄漏停止了。