IBM MQ Failover test setup - nats-io/nats-jms-bridge GitHub Wiki

IBM MQ Failover test

Creating a docker compose file

# Test that uses docker image of mult IBM MQ, Nats and active mq.
# Use this docker compose file to test IBM MQ failover.
# We change the IBM MQ port forward to run many docker instances at the same time
version: '3'
services:
  nats-server:
    build:
      context: ../bridge-nats-server-tls
    ports:
      - "4222:4222"
      - "8222:8222"
  active-mq:
    build:
      context: ../bridge-activemq
    environment:
        - ARTEMIS_USERNAME=cloudurable
        - ARTEMIS_PASSWORD=cloudurable
    ports:
      - "8161:8161"
      - "61616:61616"
  ibm-mq_1:
    build:
      context: ../bridge-ibmmq
    environment:
      - LICENSE=accept
      - MQ_QMGR_NAME=QM1
      - MQ_APP_PASSWORD=passw0rd
    ports:
      - "1414:1414"
  ibm-mq_2:
    build:
      context: ../bridge-ibmmq
    environment:
      - LICENSE=accept
      - MQ_QMGR_NAME=QM1
      - MQ_APP_PASSWORD=passw0rd
    ports:
      - "1415:1414"
  ibm-mq_3:
    build:
      context: ../bridge-ibmmq
    environment:
      - LICENSE=accept
      - MQ_QMGR_NAME=QM1
      - MQ_APP_PASSWORD=passw0rd
    ports:
      - "1416:1414"

Install guide for NATS JMS/MQ Bridge

Download the distribution zip and unzip it

mkdir bridge
cd bridge

wget https://github.com/nats-io/nats-jms-mq-bridge/releases/download/0.19.0-beta15/nats-bridge-admin-0.19.0-beta15.zip
unzip nats-bridge-admin-0.19.0-beta15.zip
rm *.zip

Before you run the server bridge

Before you run the server you may want to download the source code and run the docker-compose out of the cicd folder which starts up IBM MQ, ActiveMQ, NATS Servers and 3 Bridges in Docker.

git clone https://github.com/nats-io/nats-jms-mq-bridge.git
cd nats-jms-mq-bridge
bin/build.sh multibm

The command bin/build.sh multibm uses docker-deploy to deploy Mult IBM MQ, ActiveMQ and NATS Servers for testing and development.

Use the follow command to see dockers running.

$ docker ps

Output:
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                                                                                 NAMES
636685f372cd        compose_ibm-mq_1      "runmqdevserver"         19 seconds ago      Up 18 seconds       9157/tcp, 0.0.0.0:1414->1414/tcp, 9443/tcp                                                            compose_ibm-mq_1_1
2cb2cc19aaeb        compose_ibm-mq_2      "runmqdevserver"         19 seconds ago      Up 18 seconds       9157/tcp, 9443/tcp, 0.0.0.0:1415->1414/tcp                                                            compose_ibm-mq_2_1
55eb6c29d1ba        compose_active-mq     "/docker-entrypoint.…"   19 seconds ago      Up 18 seconds       1883/tcp, 5445/tcp, 5672/tcp, 9404/tcp, 0.0.0.0:8161->8161/tcp, 61613/tcp, 0.0.0.0:61616->61616/tcp   compose_active-mq_1
4bb3344b9746        compose_ibm-mq_3      "runmqdevserver"         19 seconds ago      Up 18 seconds       9157/tcp, 9443/tcp, 0.0.0.0:1416->1414/tcp                                                            compose_ibm-mq_3_1
c47c68d248a1        compose_nats-server   "docker-entrypoint.s…"   19 seconds ago      Up 18 seconds       0.0.0.0:4222->4222/tcp, 0.0.0.0:8222->8222/tcp, 6222/tcp                                              compose_nats-server_1

You have 3 IBM-MQ running: compose_ibm-mq_1_1, compose_ibm-mq_2_1, compose_ibm-mq_3_1

Run the application

cd ..
pwd
~/bridge

cd nats-bridge-admin-*

Run the server

bin/nats-bridge-admin
Output

 .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
 '  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v2.2.6.RELEASE)

2020-05-01 03:22:06.114  INFO 92828 --- [           main] io.nats.bridge.admin.ApplicationMain     : Starting ApplicationMain on Richards-MacBook-Pro.local with PID 92828 (/Users/richardhightower/bridge/nats-bridge-admin-0.11.1-beta7/lib/nats-bridge-admin-0.11.1-beta7.jar started by richardhightower in /Users/richardhightower/bridge/nats-bridge-admin-0.11.1-beta7)
2
...
2020-05-01 03:22:09.211  INFO 92828 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-05-01 03:22:09.214  INFO 92828 --- [           main] io.nats.bridge.admin.ApplicationMain     : Started ApplicationMain in 3.409 seconds (JVM running for 3.688)

Note that after you run the bridge for the first time the following files should be present in the config folder.

ls config/*

config/initial-nats-bridge-logins.json	config/logback.xml			config/nats-bridge.yaml
config/initial-nats-bridge-logins.yaml	config/nats-bridge-logins.yaml

Using the command line tools

To use this tool you must install jq. jq is a lightweight command-line JSON processor. https://stedolan.github.io/jq/ (brew install jq or sudo apt-get install jq or https://stedolan.github.io/jq/download/)

If you did not run the integration test then you need to generate the token file before you use the admin.

To set up admin tool for the first time from the NATS Bridge Admin directory run set-up-admin

  $ bin/admin.sh set-up-admin

This will create the admin token under config/admin.token. This token is a JWT token that gets used by the admin. Once you generate the admin.token, you may want to delete the config/initial-nats-bridge-logins.yaml and config/initial-nats-bridge-logins.json files.

See that the token file exists:

ls config/*
config/admin.token			config/initial-nats-bridge-logins.yaml	config/nats-bridge-logins.yaml
config/initial-nats-bridge-logins.json	config/logback.xml			config/nats-bridge.yaml

Note the config/admin.token file that was generated from set-up-admin.

Copying the nats-bridge.yaml file to run this test

rm config/nats-bridge.yaml
cp sampleConf/ibm_mq_failover_request_reply.yaml config/nats-bridge.yaml

Run the server again and check if you don't have errors

bin/nats-bridge-admin

Running the test and kill ibm mq to see failover

Open another terminal and prepare to kill the first IBM MQ docker

docker ps

CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                                                                                 NAMES
340e3327625b        compose_ibm-mq_1      "runmqdevserver"         33 minutes ago      Up 33 minutes       9157/tcp, 0.0.0.0:1414->1414/tcp, 9443/tcp                                                            compose_ibm-mq_1_1

Prepare the command to kill the docker

docker kill 340e3327625b

Open another terminal and go to the bridge folder

cd ~/bridge/nats-bridge-admin-*

$ bin/integration.sh

Kill the docker in the other terminal, you will see that the job still running

If you want, repeat this step and kill the second IBM MQ docker.