Reputation: 124
Currently, I am using javax.jms.ConnectionFactory with Apache Camel and Spring Boot for messaging. I want to use connection pool for connecting IBM MQ in Spring bean. How can I do that?
Upvotes: 0
Views: 5493
Reputation: 44685
On the IBM MQ server there should be a java/lib
folder containing the JAR files you need for connecting to IBM MQ, as is being mentioned within the IBM Knowledge Center:
Within an enterprise, the following files can be moved to systems that need to run IBM MQ classes for Java applications:
- com.ibm.mq.allclient.jar
- com.ibm.mq.traceControl.jar
The file
com.ibm.mq.allclient.jar
contains the IBM MQ classes for JMS, the IBM MQ classes for Java, and the PCF and Headers Classes. If you move this file to a new location, make sure that you take steps to keep this new location maintained with new IBM MQ Fix Packs. Also, make sure that the use of this file is made known to IBM Support if you are getting an interim fix.
Within these JAR files, you can find an implementation of ConnectionFactory
, called MQQueueConnectionFactory
. You have to add the necessary JAR files to the classpath of your application, and then you can configure the ConnectionFactory
, for example:
@Bean
public ConnectionFactory ibmConnectionFactory() throws JMSException {
MQQueueConnectionFactory connectionFactory = new MQQueueConnectionFactory();
// Change this to the hostname of the IBM MQ server
connectionFactory.setHostName("myhost.example.org");
connectionFactory.setPort(1414);
// Change this to the queue manager you use
connectionFactory.setQueueManager("MQ_NAME");
connectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
// Create your own channel in stead of using SYSTEM.DEF.SVRCONN
connectionFactory.setChannel("SYSTEM.DEF.SVRCONN");
return connectionFactory;
}
Upvotes: 0