Integrate Any JMS-Compliant Message Broker
In this procedure, you will learn how the jms service allows you to configure Kaazing Gateway to connect to any back-end JMS-compliant message broker.
JMS broker implementations provide a factory class in their JAR files. (For example, the Apache ActiveMQ factory class that ships in the Kaazing Gateway bundle is org.apache.activemq.jndi.ActiveMQInitialContextFactory
in the JAR file activemq-client-5.10.0.jar
.) To use the jms
service with a JMS-compliant message broker, you would copy the jar file to GATEWAY_HOME/lib/ext
and specify the name of the factory class in the service configuration element.
Note: Java Naming and Directory Interface (JNDI) is a Java API for looking up objects by name (a directory service). With the Gateway, you use JNDI in two ways: 1. to set up the initial context and call the Kaazing Gateway JMS Client Library from your JMS client or 2. to connect from the Gateway to your JMS-compliant message broker and lookup topics and queues. This section focuses on the latter, where you want to configure the Gateway to communicate with your message broker. For information about setting up JMS clients, see the appropriate client developer topics in For Developers.
For information on integrating the Gateway with specific JMS-Compliant Message Brokers, see:
- Integrate TIBCO Enterprise Message Service
- Integrate RabbitMQ Messaging
- Integrate Informatica Ultra Messaging
- Integrate IBM WebSphere MQ
- Integrate JBoss Messaging
- Integrate Open MQ Messaging
- Integrate Oracle WebLogic JMS
- Integrate Apache ActiveMQ
To Integrate Any JMS-Compliant Message Broker
To use the jms
service, you must perform the following steps:
- Copy the JMS-compliant message broker’s client-specific JAR files to
GATEWAY_HOME/lib/ext
. - Configure a
jms
service on the Gateway with the properties and values for the JNDI initial context factory. The Gateway creates an initial context with a set of properties, which are specific to the JMS-compliant message broker. These properties may vary based on the configuration of your message broker, and may involve references to LDAP systems. These properties map to theenv.*
properties listed in jms; when you use these properties, the Gateway uses their values to create the initial context. - Configure the connection factory name to connect to your JMS-compliant message broker. The Gateway creates the initial context, then uses it to obtain a connection factory by looking up the name you enter here. The name you enter here should be one of the classes included in the broker JAR file that you placed into the
/lib
directory in Step 1. -
Configure the context lookup topic format and context lookup queue format to inform
jms
service what format to use when looking up topics and queues in the broker. The Gateway follows this format when it attempts to fetch the reference to a topic or queue from the initial context.Note: For brokers that do not use destination lookups through JNDI (such as Informatica Ultra Messaging), you can add another property to the jms section in the
gateway-config.xml
file calleddestination.strategy
, and set its value tosession
. This configuration instructs the Gateway to obtainTopic
andQueue
objects using thecreateTopic()
andcreateQueue()
JMS API methods instead of performing JNDI lookups. -
Once you have configured the
jms
service for the Gateway with the appropriate initial context properties and the connection factory name, save thegateway-config.xml
and restart the Gateway. The Gateway then creates the connection using the connection factory.Note: Additional
env.java.naming
properties can be specified. Refer to the summary inhttps://docs.oracle.com/javase/jndi/tutorial/beyond/env/source.html
andhttps://docs.oracle.com/javase/8/docs/api/javax/naming/Context.html
for a complete list. The Gateway does not enforce any of these property values; it just passes them to the JMS API.
The following is an example of a service
element of type jms
.
<service> <accept>ws://localhost:8000/jms</accept> <accept>wss://localhost:9000/jms</accept> <type>jms</type> <properties> <connection.factory.name>ConnectionFactory</connection.factory.name> <env.java.naming.factory.initial> org.apache.activemq.jndi.ActiveMQInitialContextFactory </env.java.naming.factory.initial> <env.java.naming.provider.url> tcp://localhost:61616 </env.java.naming.provider.url> <destination.strategy>session</destination.strategy> </properties> <cross-site-constraint> <allow-origin>http://localhost:8000</allow-origin> </cross-site-constraint> <cross-site-constraint> <allow-origin>https://localhost:9000</allow-origin> </cross-site-constraint> </service>
Notes
- If you use a JMS-compliant message broker that does not support individual message acknowledgement, you must ensure your client applications acknowledge each message received from a queue or durable subscriber. Otherwise, the client will receive only one message from that queue or durable subscriber.
- To learn how to secure your JMS configuration, see Secure Your JMS Configuration.
- Client applications (using the Kaazing Gateway JMS client library) can lookup/create their
Topic
andQueue
objects using either thesession.createTopic()
method (for example,Topic myTopic = session.createTopic("/topic/myTopic");
) or by performing a JNDI lookup using theinitialContext.lookup()
method (for example,Topic myTopic = initialContext.lookup("/queue/myQueue");
). TheinitialContext.lookup()
method is available to use after creating the JNDIInitialContext
object when creating the JMS connection.
See Also
- For information on troubleshooting JMS integration, see Troubleshoot JMS Integration.
- For information on troubleshooting JMS clients, see Troubleshoot Your Clients.
- For general troubleshooting information, see Troubleshoot Kaazing Gateway.