Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

We are working on an IBM WebSphere MQ application, and we use JMS API to operate the message. But we have a problem that the connection takes too much time, and we want to pool the JMS connection, for it's a standalone application, we have no application container to provide JNDI or pooling service. So is there a solution to resolve this? For JDBC we can use DBCP or c3p0 to archive pooling datasource, in JMS, is there any similar project that can pool JMS connections?

like image 649
phyerbarte Avatar asked Jan 19 '12 07:01

phyerbarte


People also ask

What is JMS pool?

pool. A JMS provider which pools Connection, Session and MessageProducer instances so it can be used with tools like Spring's JmsTemplate.

How does Connection pool work in Java?

Connection pooling means that connections are reused rather than created each time a connection is requested. To facilitate connection reuse, a memory cache of database connections, called a connection pool, is maintained by a connection pooling module as a layer on top of any standard JDBC driver product.

What is JMS connection factory and queues?

A JMS queue connection factory is used to create connections to JMS destinations. When an application needs a JMS queue connection, an instance can be created by the factory for the JMS provider that is named in the Provider column of the list. This type of connection factory is for applications that use the JMS 1.0.


1 Answers

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.

like image 186
Nicholas Avatar answered Nov 15 '22 09:11

Nicholas