Admin Bridge Share Work (multi bridge sharing work) - nats-io/nats-jms-bridge GitHub Wiki
Admin Bridge Share Work Walkthrough
Creating a Docker Image with the latest bridge version
FROM ubuntu:20.04
#Copying files
COPY . ./usr/app
WORKDIR /usr/app
#Install some dependencies
RUN apt-get update
RUN apt-get -y install curl unzip zip wget nano jq
# Install SDK MAN
RUN chmod +x cicd/sdkman.sh
RUN exec cicd/sdkman.sh
# Install Java & Gradle
RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk install java 8.0.262-amzn"
RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk install gradle"
ENV JAVA_HOME /root/.sdkman/candidates/java/current
#Downloading the latest version
WORKDIR /usr/app/bridge
RUN bash -c "wget https://github.com/nats-io/nats-jms-mq-bridge/releases/download/0.19.0-beta15/nats-bridge-admin-0.19.0-beta15.zip"
RUN bash -c "unzip nats-bridge-admin-0.19.0-beta15.zip"
RUN bash -c "rm *.zip"
#Creating certs folder
RUN bash -c "mkdir certs"
#Copying certs
RUN bash -c "cp -r /usr/app/certs/* certs/"
Building and uploading docker image
$ pwd
Output:
~/nats-jms-mq-bridge2/bridge2
$ docker build -f cicd/gradle_version/Dockerfile -t cloudurable/multi-bridge .
Final Output:
Successfully tagged cloudurable/multi-bridge:latest
$ docker push cloudurable/multi-bridge
Output:
latest: digest: sha256:ee5cdc79a72de5ed9721628773c59bd2804ae4ad4dea05dd04eb7f46ae7460db size: 3884
Creating a docker compose file
# Test that uses docker image of IBM MQ, Nats, active mq and Multbridge instances.
# Use this docker compose file to test bridge share work.
# We change the bridge port forward because we will run admin in the localhost too.
# You can create as many bridge admin as you want/need
version: '3'
services:
nats-server:
build:
context: ../bridge-nats-server
ports:
- "4222:4222"
- "8222:8222"
ibm-mq:
build:
context: ../bridge-ibmmq
environment:
- LICENSE=accept
- MQ_QMGR_NAME=QM1
- MQ_APP_PASSWORD=passw0rd
ports:
- "1414:1414"
- "8443:9443"
active-mq:
build:
context: ../bridge-activemq
environment:
- ARTEMIS_USERNAME=cloudurable
- ARTEMIS_PASSWORD=cloudurable
ports:
- "8161:8161"
- "61616:61616"
bridge-admin_1:
container_name: bridge-admin_1
image: 'cloudurable/multi-bridge'
environment:
- TARGET=host.docker.internal
working_dir: /usr/app/bridge
command: ["sleep","infinity"]
ports:
- "8070:8080"
bridge-admin_2:
container_name: bridge-admin_2
image: 'cloudurable/multi-bridge'
environment:
- TARGET=host.docker.internal
working_dir: /usr/app/bridge
command: ["sleep","infinity"]
ports:
- "8090:8080"
bridge-admin_3:
container_name: bridge-admin_3
image: 'cloudurable/multi-bridge'
environment:
- TARGET=host.docker.internal
working_dir: /usr/app/bridge
command: ["sleep","infinity"]
ports:
- "8060:8080"
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 multbridge
The command bin/build.sh multbridge uses docker-deploy to deploy IBM MQ, ActiveMQ, NATS Servers and 3 Bridges for testing and development.
Use the follow command to see dockers running.
$ docker ps
Output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6b7e7d1544a2 compose_nats-server "docker-entrypoint.sâŚ" 3 minutes ago Up 3 minutes 0.0.0.0:4222->4222/tcp, 0.0.0.0:8222->8222/tcp, 6222/tcp compose_nats-server_1
07a8b085d1c1 cloudurable/multi-bridge "sleep infinity" 3 minutes ago Up 3 minutes 0.0.0.0:8090->8080/tcp bridge-admin_2
8a29b378b235 compose_ibm-mq "runmqdevserver" 3 minutes ago Up 3 minutes 0.0.0.0:1414->1414/tcp, 9157/tcp, 0.0.0.0:8443->9443/tcp compose_ibm-mq_1
3c923450dc7f cloudurable/multi-bridge "sleep infinity" 3 minutes ago Up 3 minutes 0.0.0.0:8070->8080/tcp bridge-admin_1
ac430609e5f5 compose_active-mq "/docker-entrypoint.âŚ" 3 minutes ago Up 3 minutes 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
60bfcdcbf735 cloudurable/multi-bridge "sleep infinity" 3 minutes ago Up 3 minutes 0.0.0.0:8060->8080/tcp bridge-admin_3
You have 3 bridge-admins running: bridge-admin_1, bridge-admin_2, bridge-admin_3
Use the sample JSSL certs
This copies the sample cert files so that the sample bridge config can find the JSSL certs.
$ pwd
~/bridge
$ mkdir certs
$ cp nats-jms-mq-bridge/certs/* certs/
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/nats-bridge-local.yaml config/nats-bridge.yaml
Run the server again and check if you don't have errors
bin/nats-bridge-admin
Running mult-bridges
To run mult-bridges we need to change the nats-bridge.yaml inside the dockers. To do that follow the steps:
Open a new terminal and list the dockers
$ docker ps
Output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
...
3c923450dc7f cloudurable/multi-bridge "sleep infinity" 40 minutes ago Up 40 minutes 0.0.0.0:8070->8080/tcp bridge-admin_1
...
I will connect to the first bridge admin using the CONTAINER ID
docker exec -it 3c923450dc7f bash
Output
root@3c923450dc7f:/usr/app/bridge#
Enter in the nats-admin folder and copy the config files
cd nats-bridge-admin-*
cp /usr/app/admin/config/* config/
Run the admin inside the docker
bin/nats-bridge-admin
Repeat this steps to the others admin dockers
Running the integration test to see the work share
Open another terminal and go to the bridge folder
cd ~/bridge/nats-bridge-admin-*
$ bin/integration.sh
You will see the bridges sharing work