How to pool the JMS connection in a standalone Java application?

柔情痞子 提交于 2019-11-29 07:41:13

It used to be that the JMS MQConnectionFactory had pooling built in, but it seems that in version 7, it has been removed.

Set the use of ConnectionPooling in earlier versions of the WebSphere MQ classes for JMS. This method is retained for compatibility with older MQJMS applications, but, because this Connection Pooling functionality has been removed from version 7, setting this property will have no effect.

In the absence of anything else, you can use Apache Commons Pool. Same idea as DBCP (which uses Pool) but for non JDBC objects.

stefan.m

Spring's CachingConnectionFactory works well for this use case. This answer in https://stackoverflow.com/a/31119435/1765341 explains how to do this in Tomcat, but the code there can easily be adapted for Java standalone applications. This should be much easier (and less error prone) than writing an Apache Commons Pool implementation.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!