In a previous blogpost, I described how you can install IBM MQ on your local development machine.This is still a lot of work just to get MQ up and running This post describes how to run IBM MQ in Docker and get you up and running in less than 5 minutes! (you should have of course already a working installation of Docker Desktop on your machine). IBM MQ is installed: In one container on the first virtual machine In two containers on the second virtual machine In this case, IBM MQ that is installed on each of the virtual machines has access to eight cores.
John Zaccone
Developer Advocate, IBM Digital Business Group
I am a Software Engineer with 6+ years of experience in software development, design and testing. My experience ranges from developing new features in large legacy DoD applications to designing services oriented architectures for enterprise applications.
I am a Docker Captain; a title I earned after dockerizing the entire application stack at Allianz in production. I commit to sharing my expertise back to the community and my clients by providing training, giving brown bags, organizing the Docker meetup in Richmond, and publishing content on my blog.
COURSE STAFF
Article ID: KB000793
Overview
This application guide illustrates how Docker Enterprise Edition 2.0 can be used to deploy an IBM MQ service communicating between two applications running on separate instances of WebSphere Liberty.
The two applications can be staged using the build
script, and the sample can then be deployed by using Docker Compose or Kubernetes. In both cases, Docker for Mac is used to prepare and validate the initial setup before deployment on Docker Enterprise Edition 2.0.
Information on IBM MQ and WebSphere Liberty is provided by Docker as a known, working configuration at the time of publishing. Docker does not support IBM MQ or WebSphere Liberty. Please contact IBM Support if you have any questions or problems with them.
IBM MQ Overview
IBM MQ (often referred to as 'MQ') is IBM's Messaging solution for Enterprise and IBM's Message Oriented Middleware offering. It allows independent applications to securely communicate with each other across multiple systems. WebSphere Application Server provides flexible and secure runtimes for mission-critical Java enterprise applications, lightweight web applications, and microservices.
These two products are often found in enterprise IT deployments. MQ is used to communicate securely between applications running in WebSphere Liberty servers.
Architecture
This deployment shows:
- MQ and two Websphere Liberty servers are deployed on Docker for Mac or Docker Enterprise Edition. A 'sender' Java application is deployed and managed by one Liberty server. A 'receiver' application is deployed and managed by the other.
- After the containers are started, the sender application creates a connection to the queue manager (QM1). The sender application puts a message on the queue (Q1). This is initiated through a web browser.
- The sender application then waits for a response from the receiver.
- The receiver application continuously monitors the queue for messages using a message-driven bean.
- The receiving application consumes the message from the queue and creates a response.
- The receiving application puts the response on a temporary response queue and closes the connection to the queue.
- The sending application then sees the message and consumes it from the queue.
- The sending application reports its progress back to the web browser and writes the same messages out to the logs.
Prerequisites
The following are prerequisites for installing IBM MQ and WebSphere Liberty:
- Docker Enterprise Edition 2.0 UCP 3.0.0 DTR 2.5.0 for Ubuntu (other platforms available)
Installation and Configuration (Docker for Mac)
Use the following steps to install and configure IBM MQ and WebSphere Liberty:
Install the
git
utility if not already installed.In a terminal window, navigate to the folder you would like to place the repository (or create a new one), then run the command:
MQ provides a resource adapter that allows WebSphere Liberty to connect to IBM MQ to enable it to send messages to a second web application. The MQ resource adapter is available throughIBM Fix Central or from the MQ installation. To locate a version that is available for download, unblock any popups from IBM, and search for the term 'InstallRA' using the search box provided. The name of the file to be downloaded is in the format of
<V.R.M.F>-IBM-MQ-Java-InstallRA.jar
.Click through the selection and agreement forms. Download the most recent resource adapter. (This guide was tested with version 9.0.5.0.)
Put the resource adapter JAR file that you downloaded into both the
liberty-sender
andliberty-receiver
application folders found in./sample.docker.mq
.Edit the
Dockerfile
in bothliberty-sender
andliberty-receiver
and ensure that the COPY commands for the resource adapter is up-to-date with the current resource adapter’s version (e.g. change9.0.5.0
in two places if necessary).In a browser and using a previously created Docker ID, log into Docker Store. Subscribe to both the Websphere Liberty and MQ Advanced images. These images are free. Here are the example steps to subscribe to the
Websphere Liberty
image. Follow the same process for theMQ Advanced
image.Subscription Screen:
Back in the terminal window, execute the following command and provide Docker credentials:
Return to the
sample.docker.mq
directory. Execute this script to compile and build the application:This script uses maven to build the WAR files for both of the applications in the sender and receiver directories and makes sure they are copied the correct locations. It also builds the images for mq, sender, and receiver parts of the application.
Verify the image creation using these Kubernetes commands:
Ibm Mq For Docker Mac Install
Verifying the Deployment for Swarm on Docker for Mac
If using Kubernetes, proceed to Verifying the Deployment for Kubernetes on Docker for Mac.
To deploy on Docker for Mac using the Swarm orchestrator, execute:
This brings up three containers: mqfull
, liberty-server
, and liberty-receiver
. A docker ps
command looks something like this:
If using Swarm, proceed to Verifying the Application on Docker for Mac.
Verifying the Deployment for Kubernetes on Docker for Mac
If Kubernetes is not already enabled, access the top menu bar of your desktop, and click on Preferences. Click on Kubernetes and choose the Enable Kubernetes check box. Click on Apply to restart Docker for Mac with Kubernetes enabled.
To deploy with the Kubernetes orchestrator, execute:
This starts three services and three deployments named mqfull
, sender
, and receiver
. Verify the Kubernetes deployment using the kubectl get
command. The output is similar to this:
Verifying the Application on Docker for Mac
Access the application, the MQ Console, and the two Liberty servers:
Application: http://localhost:31080/sender/
Output to log files upon refresh of browser:
MQ Console: https://localhost:30443/ibmmq/console/login.html (admin/passw0rd)
liberty-sender
is at https://localhost:31443/adminCenter/login.jsp (wsadmin/wsadmin); likewise,liberty-receiver
is at https://localhost:31444/adminCenter/login.jsp.
Stopping the Application using Swarm on Docker for Mac
If using Kubernetes, proceed to Stopping the Application using Kubernetes on Docker for Mac.
To stop the application, execute:
Proceed to Configuration and Deployment on Docker Enterprise Edition.
Ibm Docker Container
Stopping the Application using Kubernetes on Docker for Mac
To stop the application, execute:
Configuration and Deployment on Docker Enterprise Edition
To deploy IBM MQ and WebSphere Liberty on Docker Enterprise Edition 2.0, begin with the provisioning of an appropriate number of nodes for site-specific performance and high availability:
In this example, a four instance deployment was provisioned consisting of one instance for UCP Management and three instances to run each of the three worker containers: MQ, Sender, and Receiver. UCP manages both Kubernetes and Swarm orchestration.
Docker Trusted Registry (DTR) is also installed on the instance with one of the worker containers. This guide assumes that UCP and DTR have been installed and configured and that access to the 'admin' account and password has been provided.
Note on Kubernetes networking: This guide defines all of the container ports using NodePort
networking. To use LoadBalancer
method instead, refer to the Troubleshooting section towards the end of this document.
Move Images to Docker EE
Move the previously tested MQ and Liberty images to Docker Enterprise Edition running on a cloud service provider. Since the original MQ and Liberty images have been extended during the build process, these extended images must be tagged and pushed into the cloud service provider environment. This can be done by pushing the local images to DTR and then altering the docker-compose.yml
so that it points to these images. (For testing purposes, a public repository on Docker Hub can be used to push the images instead of DTR.)
Log into the DTR Mangement Console (at https://{dtr-registry-address}) as 'admin'.
Click on the New repository button towards the upper right portion of the window.
In the New Repository name field, enter
test-mq
, and then click on Create.Create two more repositories named
test-sender
andtest-receiver
. The new repositories should look like this:Logout of the DTR UI.
From a new terminal window on Docker for Mac/Linux, execute:
When prompted, enter 'admin' as the username and then the appropriate password.
Prepare the images created in the previous steps for DTR:
Push images to DTR:
Deployment and Verification on Docker Enterprise Edition using Swarm
If using Kubernetes, proceed to Configuration and Deployment on Docker Enterprise Edition using Kubernetes.
In a browser, access the URL for the UCP management node and login as 'admin'.
Click on Shared Resources in the left sidebar:
Click on Stacks:
On the Shared Resources screen, click on Create Stack in the upper right corner:
On the Create Stack screen, provide a Stack Name and choose Services as the Mode. From the
sample.docker.mq
directory, upload the filedocker-compose-EE.yml
. Change the three fields `{dtr-registry-address} to the actual address name of the Docker Trusted Registry. Click Create to launch the deployment:To verify that the containers lauched successfully, click on
Services
in the left side bar on the UCP home screen. Themqfull
,liberty-sender
, andliberty-receiver
show with green status and no errors. The endpoint URLs can be accessed for each container by clicking on the name and inspecting the right hand configuration menu bar that appears.To verify it is functioning correctly, connect to http://{ucp-ip-address}:34080/sender/ . After each screen refresh, the sender posts a message to receiver. The receiver answers with a message back. Other console applications are available as described in the previous section _Verifying the Application on Docker for Mac.
Configuration and Deployment on Docker Enterprise Edition using Kubernetes
In a browser, access the URL for the UCP management node and login as 'admin'.
Click on Kubernetes in the left sidebar, and then click on +Create.
On the Create Kubernetes Object screen, choose default in the Namespace dropdown menu. From the
sample.docker.mq
directory, upload the filemq-kubernetes-EE.yaml
. Change the three fields{dtr-registry-address}
to the actual address name of the Docker Trusted Registry. Click Create to launch the deployment.To verify that the containers launched successfully, click on Pods in the left sidebar on the UCP home screen. The
mqfull
,liberty-sender
, andliberty-receiver
show with green status and no errors.To bring up the application, click on Load Balancers in the Kubernetes section on the left sidebar. Choose sender in the list of load balancers. A configuration bar appears on the right. Choose the address with port 34090 to bring up the IBM Liberty web screen. Add
'/sender/'
to the URL in the browser to test the application.
After each screen refresh of `http://{ucp-address}:34090/sender/, the sender posts a message to receiver. The receiver answers with a message back.
Other applications are accessible:
MQ Console
: https://{ucp-ip-address}:33443/ibmmq/console/login.html (admin/passw0rd)liberty-sender Console
: https://{ucp-ip-address}:34443/adminCenter/login.jsp (wsadmin/wsadmin)liberty-receiver Console
: https://{ucp-ip-address}:34444/adminCenter/login.jsp (wsadmin/wsadmin)
If using Kubernetes, proceed to Stopping Application on Enterprise Edition using Kubernetes.
Stopping the Application on Enterprise Edition using Swarm
To stop the solution, click on Stacks in the left sidebar, and then click on the 'Name' of the stack. A menu bar appears on the right. Click on Remove to stop and remove the containers.
Stopping the Application on Enterprise Edition using Kubernetes
To stop the solution, remove both the Controller entries for mqfull
, sender
, and receiver
. Also remove the Load Balancer entries for the same.
Troubleshooting
The following are known issues and how to workaround them.
Ibm Mq For Docker Mac Os
If errors occur in the build or the sender/receiver communication, it may be necessary to re-build after removing all images and clearing cashes. This can be achieved using the following commands:
Depending on your deployment circumstances, it may be necessary to list the
{dtr-registry-address}
in the Docker 'insecure registries' table found under Preferences -> Daemon in the menu of the Docker toolbar icon. If you receive certificate errors, this is a likely cause.Make sure that the Nodes listed in the Shared Resources tab have the correct mix of
Kubernets
,Swarm
, orMixed
resources available.DTR certificates: In the case of a new EE installation, the
docker push
does not work, by default, with a registry endpoint that has a self-signed TLS certificate. You can use one of four options to overcome this:- Upload your certificates signed by trusted CA to DTR by following the docs.This is the recommended way, and UCP will be able to download images from DTR.
- Modify the Docker engine config from where you will be uploading the image, and add the DTR URL among the 'insecure registries' by following steps from the Docker docs. Since UCP/Swarm will be downloading images from DTR, these settings willneed to be applied to each engine on UCP. This can be done by UCP by following the docs.
- Trust DTR's self-signed certificate on local machine. Since UCP/swarm will be downloading images from DTR, DTR's CA certificate will need to be added to all the engines in UCP.
- If Docker Trusted Registry is not available, Docker Hub or another registry can be used to push and pull the
mqfull
,sender
, andreceiver
images.
On UCP, if the Kubernetes pods show as 'Pending', check to make sure that the
{DTR-address} is entered correctly in the
mq-kubernetes.yaml` uploaded file.LoadBalancer
service type: the example in this application guide employs theNodePort
service type. To useLoadBalancer
networking, the filemq-kubernetes-EE-LB.yaml
under thesample.docker.mq
directory defines all of the application and console ports usingtype: LoadBalancer
. Use the file in step 3 of the previous section Configuration and Deployment on Docker Enterprise Edition using Kubernetes.
Further Reading
Refer to the following links for additional information:
- Developer Works Blog: This is the original guide for the MQ-Liberty demo published in Jan 2017.
Additional Application Guides and Solution Briefs
Docker provides additional application guides on success.docker.com as well as Solution Briefs about related information.