How to combine a JMS connection in a standalone Java application?

We are working on an IBM WebSphere MQ application and we use the JMS API to manage the message. But we have a problem that the connection takes too much time, and we want to combine the JMS connection, since this is a stand-alone application, we do not have an application container to provide JNDI or the unification service. So, is there a solution to solve this? For JDBC, we can use DBCP or c3p0 to archive the data pool in JMS, is there any similar project that can combine JMS connections?

+4
source share
2 answers

There used to be a JMS MQConnectionFactory , but it looks like it was removed in version 7.

Specify the use of ConnectionPooling in earlier versions of WebSphere MQ for JMS. This method is retained for compatibility with older MQJMS applications, but since 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 the Apache Commons Pool . Same idea as DBCP (which uses the pool), but not for JDBC objects.

+5
source

Spring CachingConnectionFactory works well for this use case. This answer at fooobar.com/questions/1391786 / ... explains how to do this in Tomcat, but the code there easily adapts to stand-alone Java applications. This should be much simpler (and less error prone) than writing an Apache Commons Pool implementation.

0
source

Source: https://habr.com/ru/post/1391784/


All Articles