Connection Pool for IBM MQ in Spring Boot - apache

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?

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;
}

Related

PCF / Cloud connector for Rabbit management API

All,
I'm running a simple SpringBoot app in PCF using a Rabbit on-demand service. The auto reconfiguration of the ConnectionFactory for the internal Rabbit service works just fine.
However I need a list of all queues on the Rabbit host. AFAIK this is only available through a call to the Rabbit management plugin (a REST API), see RabbitManagementTemplate::getQueues. This class expects an http URI with credentials.
I know the URI+credentials are exposed through the vcap.service variables as "http_api_uri', but I wonder if there's a more elegant way to get an instance of RabbitManagentTemplate with Spring magic cloud connectors / auto reconfiguration instead of manually reading the env vars and writing custom bean config.
It seems the ConnectionFactory only knows about the AMQP interface, and cannot create a RabbitManagementTemplate?
Thanks!
Spring Cloud Connectors won't help you here. It doesn't support setting up RabbitManagementTemplate, only a ConnectionFactory.
You don't have to parse the env yourself, you can use the flattened properties that Boot provides such as vcap.services.rabbitmq.credentials.http_api_uri. But you'll need to configure a RabbitManagementTemplate yourself using those Boot properties.

ActiveMQ 5.11 with WebSphere Application Server 8.5

Does anybody know which jars from ActiveMQ 5.11 I need to use with IBM Websphere Application Server 8.5 in order to create a new ActiveMQ JMS Provider?
I found discussions related to older ActiveMQ versions that don't seem applicable anymore because the way ActiveMQ is packaged has changed:
https://www.ibm.com/developerworks/community/blogs/timdp/entry/using_activemq_as_a_jms_provider_in_websphere_application_server_7149?lang=en
ActiveMQ 5.11 doesn't seem to have activemq-core anymore, activeio-core is under "optional", and ActiveMQ seems to have switched from commons-logging to slf4j, which in itself seems to cause problems due to the fact that WAS itself ships an outdated version of the slf4j jars (see other questions here on SO).
Any advice is highly appreciated.
Figured it out. It's really simple actually. In the WAS console, go to Resources -> JMS -> JMS Providers, and create a new provider as:
Classpath:
C:/activemq-libs/activemq-client-5.10.0.jar
C:/activemq-libs/hawtbuf-1.10.jar
C:/activemq-libs/slf4j-api-1.7.5.jar
External initial context factory:org.apache.activemq.jndi.ActiveMQInitialContextFactory
External provider URL: tcp://myhost:61616
Then go to Resources -> JMS -> Queue Connection Factories and create a new one as:
Name: myQCF
JNDI Name: jms/myQueueConnectionFactory
External JNDI Name: QueueConnectionFactory
You can create a new Queue as (Resources -> JMS -> Queues):
Name: myQueue
JNDI Name: queue/myQueue
External JNDI Name: dynamicQueues/myQueue
Maarten

TomEE, rabbitmq

I am working on developing an interface between TomEE application server and rabbitmq.
Is there any example that can show me what is to be configured in the tomEE server ?
How can I initiate tomEE to create a exchange and queue and than send out messages ?
not sure I fully got the question bu you can embed java client in your application and use Java API: http://www.rabbitmq.com/tutorials/tutorial-one-java.html
If you want to use JMS you can rely on https://github.com/imatix/openamq-jms but since there is no rabbitmq resource adapter it is still "manual".

weblogic 12c + websphere mq 6

I'm can't find instruction for integration websphere mq 6 + weblogic 12 c by websphere native protocol (no jms!). It possible? Goal - deploy mdb in weblogic for getting message from websphere mq queue.
and response.
Please help with link or instruction.
Alex
I understand that the option of using WebLogic's Foreign JMS provider configuration is not available to you as you want to NOT use the JMS API, but MQ's specific API, correct?
If that is the case you could always try to write some MQ Client code using the MQ API, as you would for a stand-alone application, and then deploy it inside WebLogic, although I'm not sure whether that would give you any real benefit.
One thing I am pretty sure you will NOT be able to do is write a Message-Driven Bean which connects to an MQ Series queue using the MQ API. MDBs are a Java EE concept and they are meant to connect to JMS providers.

Setting up WebSphere MQ integration in a WebLogic clustered environment

I have a WebLogic cluster up and running an application containing an MDB. I'm currently using WebLogic JMS queues to send messages to the MDB. All is well.
I now have need to switch to IBM WebSphere MQ for my JMS messaging.
I can set this up and send/receive messages in a non-clustered environment (Admin server) using a Foreign server with a bindings file. However, I can't seem to properly configure the clustered environment for MQ integration to work correctly.
I get the following when deploying the EAR/MDB on the cluster:
The Message-Driven EJB: xxxMDB is unable to connect to the JMS destination...
javax.naming.NameNotFoundException: Unable to resolve 'jms.xxxQueue'
Can anyone point me to some documentation on how to configure IBM WebSphere MQ in a WebLogic cluster?
Thanks!
there is a need to add several MQ JMS classes to the PATH of the weblogic so it will be able to connect to MQ
the path needed to be added is : *MQ_system_path*/java/lib64
beside that here are the clasess i have found that are needed to make this thing :
com.ibm.mq.mqi.jar; com.ibm.mq.headers.jar; com.ibm.mq.jar; commonservices.jar; com.ibm.mq.jms.jar;jta.jar;
this what helped us to connect weblogic to MQ
regards
Oren yeger