Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

JMS via ActiveMQ with Kaazing Gateway Enterprise Edition

This tutorial shows how to subscribe and publish data from HTML5 clients to a JMS broker via Kaazing Gateway.

Getting Started

To run this example:

  • You must have Docker and Docker Compose installed
  • You must have host file entry for kaazing.example.com pointing to 127.0.0.1.

The docker-compose.yml file describes the three containers it will run: the Gateway, an ActiveMQ JMS broker, and a publisher generating data. These containers are launched in the following configuration:

JMS architecture

The Gateway container will run a jms service that enables WebSocket clients to connect on the front-end. The Gateway config file is configured with a jms service as follows:

<service>
  <name>JMS Demo Service</name>
  <description>A demo JMS service</description>
  <accept>ws://kaazing.example.com:8000/jms</accept>

  <type>jms</type>

  <properties>
    <connection.factory.name>ConnectionFactory</connection.factory.name>
    <context.lookup.topic.format>dynamicTopics/%s</context.lookup.topic.format>
    <context.lookup.queue.format>dynamicQueues/%s</context.lookup.queue.format>
    <env.java.naming.factory.initial>org.apache.activemq.jndi.ActiveMQInitialContextFactory</env.java.naming.factory.initial>
    <env.java.naming.provider.url>tcp://activemq:61616</env.java.naming.provider.url>
    <connection.security.principal>admin</connection.security.principal>
    <connection.security.credentials>admin</connection.security.credentials>
  </properties>

  <cross-site-constraint>
    <allow-origin>*</allow-origin>
  </cross-site-constraint>
</service>

Run

  1. Start the containers
docker-compose up -d --build

If you want to see the logs while the containers start, run:

docker-compose logs -f
  1. Once all three containers are running, connect to the Gateway in a browser via https://kaazing.example.com:8000/.

    This is a generic JMS demo app that lets you perform different JMS operations. Ordinarily these details would be not be surfaced in an end user application, but they are exposed here to let you try different aspects of using JMS on the client.

  2. Set the Location field to ws://kaazing.example.com:8000/ and press Connect.

  3. Set the Destination field to /topic/stocks and click Subscribe. You'll see messages streaming from the publisher, through the JMS broker and Kaazing Gateway to the client.

  4. On the bottom-right of the screen, click *Unsubscribe.

  5. Change the Destination field to say /topic/mytopic and click Subscribe.

  6. Open another tab or browser to the same URL: https://kaazing.example.com:8000/.

  7. Set Location to ws://kaazing.example.com:8000/jms and hit Connect.

  8. Change the *Destination field to /topic/mytopic.

  9. Put any text you want into the Message field and click Send.

  10. Go back to your first browser tab and see that it received the message. It had done a round trip from the second browser tab, through Kaazing Gateway, to the JMS broker, then back through Kaazing Gateway to the first browser tab.

    If you had also subscribed to the same topic in the browser tab, you'd see the message displayed there, too, having made the same round trip.

More detail

The gateway installation includes a conf directory containing files that control your gateway's configuration. Look at the Docker Compose file, docker-compose.yml, to see how the default files are overriden.

Look at the volumes section of the gateway service:

    volumes:
      - ./gateway/conf/gateway-config.xml:/kaazing-gateway/conf/gateway-config.xml:ro

That shows how to override the gateway-config.xml configuration file with your own. You can do the same thing for other configuration files usually used in gateway configurations, like a keystore and truststore, log configuration, etc.