Is it possible to create a common JMS listener for both IBM MQ and ActiveMQ Artemis? - jms

I have created a Maven module with all configuration for ActiveMQ Artemis. I have done the same for IBM MQ.
I am building two separate jars for above modules.
Now I have added both jars to the classpath of my microservice.
I am struggling to find a way to load one of the above jar file based on some configuration such as active.broker = artemis or ibm mq.

Given that both ActiveMQ Artemis and IBM MQ provide JMS client implementations it should be relatively straight-forward to use the same JMS application with either.
Both ActiveMQ Artemis and IBM MQ JMS clients include JNDI implementations which can be used to "lookup" their respective admin objects (e.g. connection factories & destinations) in a standard way. You only need to swap the InitialContext configuration parameters when using ActiveMQ Artemis vs. IBM MQ.

Related

How to bridge between IBM MQSeries and ActiveMQ Artemis 7.x?

Has anyone succeeded in creating a bridge between IBM MQSeries (MQS) and ActiveMQ Artemis 7.x (AMQ 7) so that the later can send messages to and receive from the first? Currently I have no problem bridging between MQS 7.5 and AMQ 6.3 by deploying a camel route and MQS libraries on the broker itself. However, the same way doesn't work anymore as each route deployment requires a broker reconfiguration and restart.
Thanks in advance for any feedback.
A few examples ship with ActiveMQ Artemis which might be helpful:
The "inter-broker-bridge" example in the examples/features/sub-modules/ directory. This example demonstrates how to deploy an instance of org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl to the broker using Spring in a web application.
The "camel" example in the examples/features/standard/ directory. This example demonstrates how to deploy a Camel route to the broker using Spring in a web application.
I can't speak to whether or not either of these can be updated at runtime as I've not actually attempted that. Both of these options should be able to move messages in either direction (i.e. from Artemis to MQS or from MQS to Artemis).
Another option would simply be to run Camel standalone and deploy your routes there. This would give you more flexibility as it would allow you to specifically choose the hardware where the routes run as well as how many resources the Camel JVM consumes. Running Camel routes directly on the broker, while convenient, isn't a great fit because the broker is a broker and not an application server.
To be clear, ActiveMQ Artemis and IBM MQSeries are not directly compatible with each other and are not expected to be. This true for most (if not all) JMS broker implementations. The role of components like the ActiveMQ Artemis JMS bridge and integration platforms like Camel are to solve the compatibility problem by using a common API to speak to both brokers - JMS in this case. Any broker which implements JMS can be integrated using these methods.

Build a standalone JMS client using JAVA

I am new to JMS and I need to build a generic JMS client to create a connection send and receive message by using queues and topics. I have seen many example using activeMQ connection factory, but I need a generic client which can use any connection factory and create a connection. Any leads or sample codes will be useful.
I have just done that recently. Steps I've taken
Read Java JMS tutorials to understand what is JMS.
You can code in Java or use a framework for example - Spring JMS
Read about MQ provider docs. for example activeMQ or IBM MQ.

Configure hornetq on Wildfly8 to send messages on JMS queue

I have recently started using Wildfly 8 and noticed that Wildfly8 has a built-in JMS utility called Hornetq. My question is, how can I configure hornetq to send and receive message on a JMS queue using Wildfly8 server?
There are a number of good tutorials on the net about how to use HornetQ (JMS) from within Widlfly, I like this one for JMS 2.0:
http://www.mastertheboss.com/jboss-server/jboss-jms/jms-20-tutorial-on-wildfly-as
Here is the hello world example from Wildfly themselves, illustrating how to implement an MDB and the respective listeners and topics:
https://github.com/wildfly/quickstart/tree/8.x/helloworld-mdb
That page describes everything in excellent detail and demonstrates the use of JMS 2.0 and EJB 3.2 Message-Driven Bean in WildFly 8. The project is runnable with maven and creates two JMS resources:
A queue named HELLOWORLDMDBQueue bound in JNDI as java:/queue/HELLOWORLDMDBQueue
A topic named HELLOWORLDMDBTopic bound in JNDI as java:/topic/HELLOWORLDMDBTopic
If you are having trouble with configuration of queues etc. in the standalone, the docs here are actually quite helpful as well:
https://docs.jboss.org/author/display/WFLY8/Messaging+configuration

Spring JMS + WebSphere MQ client

I was trying to configure jms template to connect to WebSphere MQ. When using Websphere client jar, there are multiple options that were set like MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING etc for Queue's and PUT and GET options like MQC.MQPMO_NEW_MSG_ID , MQC.MQGMO_WAIT, MQC.MQMO_MATCH_CORREL_ID etc.,.,
is there way to pass these option to JMS template ?
These options are IBM MQ specific, so don't think they can be passed as it is to Spring. But some of these have a JMS equivalent available in Spring template.
MQC.MQOO_OUTPUT option means open queue for putting messages and is equivalent to JMS createProducer API.
MQC.MQGMO_WAIT option is equivalent to receive(timeout)
MQC.MQMO_MATCH_CORREL_ID - is equivalent to creating a consumer with a selector "JMSCorrelatoinID=<your correlationid>"

MDB deployed on JBOSS fetching messages from IBM MQ

I would like to deploy MDB on JBOSS. But the publisher will not send messages to the JBOSS AS, it is sending messages to IBM MQ.
Should I use JCA to integrate JBOSS and IBM MQ?
OR
Can the MDB on JBOSS AS subscribe to the topic on which IBM MQ is getting messages from publisher?
What are the advantages of one approach to another?
The recommended way to consume messages in JBoss from IBM MQ is via a Message Driven Bean (MDB). This is done by deploying the IBM JCA resource adapter (RA) in JBoss. You must use the IBM RA in JBoss as this rar file contains the IBM MQ client code that is needed for communicating with IBM MQ.
When using the MDB approach, the container (JBoss, in this case) works with the JCA to manage JMS connections, message delivery and transactions. This leaves you to only write the onMessage() method - quite a lot gets done for you under the hood.
Yes you can certainly have an MDB in JBoss that is subscribed to a Topic on MQ,
You should deploy the WebSphere MQ Resource Adapter (WMQRA) into JBoss and then configured the WMQ RA JCA resources in JBoss (Activation Specification, Queue/Topic). This will then let you deploy your MDB, and the JCA resources will handle the connection to the WMQ Queue Manager and Queue/Topic that your messages are on.
There are a few guides on setting up the WMQ RA in JBoss around on the internet.

Resources