IBM Support

Deploying an EGL-based Microservice Application on Azure cloud Environment

White Papers


Abstract

Sasipriya B
Senior Software Engineer

This whitepaper describes the deployment of Microservice applications in a Cloud Environment as containers using Kubernetes where they can communicate with one another.
A basic client application developed in RBD using EGL publishes/subscribes a message to IBM MQ queue using topic string and prints the status of the message in the console (in the client browser page and the service logs) through REST service.

Content

Introduction

In today's fast-moving world, Customers and Companies demand to deliver a wide range of services through the internet. Cloud computing plays a vital role in our day-to-day life as it can store and access data and programs over the internet instead of on a hard drive. Therefore, businesses of any size can harness powerful software and IT infrastructure to become expandable, leaner, and compete with many larger companies. Unlike traditional hardware and software, cloud computing helps businesses stay at the forefront of technology without significant investments in purchasing, maintaining, and servicing equipment.

Benefits:

  • Lower Costs and More Efficient
  • Improved Security
  • Maintaining Business Continuity
  • Agility & Adaptability
  • Automatic Updates

 So far, Rational Business Developer works on a multi-platform and now moving beyond by building applications on the cloud network.

Prerequisites 

Hardware support: Windows 10 64 bit
  • Activated Azure subscription with Kubernetes Cluster - https://portal.azure.com/#home
  • Ubuntu terminal (Windows using WSL/Linux) with docker installed - How To Install and Use Docker on Ubuntu 20.04 | DigitalOcean
    • Or can use Docker desktop - https://docs.docker.com/desktop/install/windows-install/ 
  • IBM Rational Business Developer (9.6 and above) 
  • Apache Tomcat server (9 and above) - https://tomcat.apache.org/download-90.cgi
  • Jar files 
    • javax.jms-api.jar - https://mvnrepository.com/artifact/javax.jms/javax.jms-api/2.0.1
    • com.ibm.mq.allclient.jar - IBM MQ Downloads for developers - IBM Developer
image-20220816110258-1
Flow chart
image 12740
Detailed Flow:
image-20220816110526-2
Explanation:
  1. Two web projects where Client and Service programs were developed in Rational Business Developer (RBD) using EGL.
  2. Web projects get converted to war files.
  3. War files are converted to a client docker image and a service docker image.
  4. Both the images get pushed to the Azure Kubernetes registry via the docker command.
  5. Deployment files of each application pull the docker images from the Azure registry using the cloud power shell.
  6. Containers get created with the respective deployment and service files. Once these containers start running, they will communicate with each other.
Working Sample Creation:
Scenario: User publishes a message to IBM MQ Queue from RBD client UI and receives back the same message on RBD client UI by subscribing it from IBM MQ Queue. 
Steps to create the projects:
For a web project, the User must set up Target Runtime where a web server should be added. The below steps demonstrate the process using Tomcat as the Web Server.
a. Creating Web Server
  1. Go to Window (in the workspace) → Show view → Servers → Right-click → New → Server
  2. Select the Tomcat server and define the hostname. Click Next.
    image 12787
  3. Browse for the Apache installation directory, Click OK and  Click Finish.
    image-20220823183310-1
  4. After completing the Tomcat server setup, the user should double-click the serverOpen Launch Configuration
    image-20220822205902-1

    Note:

    • If the server is running, stop the server and go to the open launch configuration tab.
    • If the 8080 port is running by some other apps, then modify the port number for both admin and HTTP ports.

    Now, the window will prompt to edit the configuration properties.

  5. Navigate to the Classpath → User Entries → Add External Jars → select the two jars from the local directory → Apply → Ok.
    image-20220822133659-7
Note: The mentioned two jars are required to communicate with IBM MQ through the JMS client (provider).
b. Creating a Project:
  1. In the RBD Workspace → Right-clickNew ProjectEGL ProjectWeb Project Project name (give project name) → Next.
    image 12744
  2. In the target runtime, select Apache Tomcat 9 server as shown below,
    image 12745
  3. Expand the project → EGL Source Right-clickNewService.
    image 12746
  4. Enter the Package and EGL source file name as below. Select Create as web (REST) service and click Finish.
    image-20220822134601-8
As shown in the below EGL program, the record declaration has a topic and subscription name that publishes a message on the queue.
image 12748
c. Creating Resource association part for MQ:
  1. Go to Serv. eglbld → right-click → Add part
    image-20220822145305-9
  2. Choose the Resource Associations part and click Next.
    image-20220822145351-10
  3. Give a name and click Finish.
    image-20220822145427-11
  4. The below tab displays the parameters specific to the MQ service. Click Add Association, give the file name, and select the File Type as mq.
    image-20220822145537-12
  5. Enter the parameter's value as shown below (password = passw0rd). Click save
    image-20220822145629-13
  6. In the service web build options, clear the checkbox to list all the parameters. Select resourceAssociations, double click the corresponding value field, and click on the dropdown to add the created MQLink part.
    image-20220822151858-14
  7. Select the checkbox to get the Final web build options as below,
    image-20220822151940-15
  8. Click on the service deployment descriptor as below,
    image 12749
  9. The service project needs to be deployed to a web project, So click on New.
    image-20220822152133-16
  10. Provide the project name and click Finish. The target project name will be displayed below.
    image-20220822152242-17image-20220822152302-18
  11. Now, Add the two jar files in the deployed web projects of both client and service, as shown below.
    image-20220822152404-19
d.   Creation of Client-side (RUI Project):
Like web project creation, create an RUI project as below.
image-20220822152547-20
  1. New EGL ProjectRich UI Project → give project name → Next.
  2. Select the necessary widget libraries and click Next.
    image-20220822152639-21
  3. Select the service project to link client and service. Click Finish.
    image-20220822152717-22
  4. Expand the RUI project → EGLSource → Right-click → New Rich UI Handler.
    image-20220822152829-23
  5. A pop-up will be displayed where the package and the source names are defined. Click Finish.
    image-20220822152921-24
  6. To create the interface for the REST service, navigate to the service project and right-click the service EGL program → EGL ServicesExtract EGL Interface…
    image-20220825185518-1
  7. The source folder picks the default one. But the interface must be in the client project, so change the source folder to the client EGL Gen Source folder. Click Finish.
    image-20220822153109-25
    The interface will be created in the client project as below,
    image-20220822153142-26
The Client will communicate with the service after creating the interface. This interface requires service binding. To add the service binding, refer to the below steps:
e. Create Service Binding:

Navigate to the deployment descriptor of Client RUI

ClientUI.egldd → Service Bindings → Add → REST service binding → Next
image-20220822155838-27image 12750
Click Browse to select the interface name.
image-20220822160045-29
The base URL is added. Click Finish.
Note: The base URL contains the hostname as my-serv, which is the name of the container, and port 8080 is the container port.
image-20220822160231-30
The service is added as shown below. 
image-20220822160305-31
In the RUI handler design page, the widgets will be dragged and dropped from pallets.
image-20220822160343-32
Use the same URL for binding the service in the client source code, as shown below.
image-20220822160422-33
Like a Service deployed to a web project, the client also deploys to a web project.
image-20220822160557-34
f.  Generation and deployment of service and client:
  1. After creating the sample, the user must generate and deploy the projects. For a service project, right-click on the service program (Serv1.egl) → Generate with Wizard Finish.
    image-20220822161338-1
  2. A successful generation will be displayed as below,
    image 12751
  3. Once Generation is successful, right-click service project (Serv) → Deploy the EGL project. The Service will get deployed to its target web project (MQService). The successful deployment will be displayed as below,
    image 12752
  4. Likewise, the Client is generated and deployed. Right-click client project (Client UI) → Generate. If the generation is successful, then the below console is displayed.
    image 12753
  5. For Deployment, Right-click client project (Client UI) → Deploy EGL project. A successful deployment will be displayed as below,
    image 12754
Creation of docker images
1. Conversion of Web projects to WAR files
Both the web projects (MQConsumer and MQService) are exported as WAR files.
image 12755
Enter the destination to store the war file on the local system.
image 12756
The file structure for the client and service in the local directory should be as below.
Convert these folders to a zip file and transfer them to the Ubuntu terminal.
image 12757
image 12759
The docker file contents for the client and service are as below,
image 12761
image 12762
Open the Windows power shell as administrator, navigate to the directory, and transfer the files to the Ubuntu terminal using the below command.

scp < zip folder name > < username@ip address:directory/> 

Example: scp client.zip azure@10.56.87.34:home/
2. Ubuntu Terminal to create the docker image 

unzip the folder and navigate to the client folder as shown below.
image-20220822172347-1   
Using the docker command, create the client and service image as below.
image-20220822172705-2
The docker image for service and client has been created as below.
image-20220822172838-3
Now, these docker images need to be moved to the azure Kubernetes registry. Navigate to the Azure portal → container registryaccess keys → copy the username and password.
image-20220822173253-4
Login to the azure registry server from Ubuntu. Use the credentials to move the docker images into the repository as below.
image-20220822173438-5
image-20220822173545-6
Both the client and service images are pushed, and the files are available in the azure repository.
image 12763
Deployment of application on Azure Kubernetes
The microservice application will run as 3 containers communicating with one another.
  • IBM MQ 
  • Service
  • Client
Each container requires deployment and service YAML files.

Note: YAML files contain the configuration details about running a container which then converts that information to JSON when making the API request. For more details about the YAML file, refer 3rd link in the reference section.
image-20220822174015-7
User must create YAML files (6 files) and upload them to the Cloud shell of Azure as shown below.
image-20220822175626-8
Click Open editor to make changes in the YAML files as shown below.
image-20220822183326-9
Start the containers
Create the containers using the “kubectl” command.
image-20220822184500-10
If successful, the deployment shows a 1/1 READY state, as shown below.
image-20220822184752-11
Navigate to the External-IP address of respective containers in the browser.
MQ Web Console
To begin with the MQ container, the URL is https://<MQContainerIP>:9443/ibmmq/console/login.html

Example:  https://52.149.195.104:9443/ibmmq/console/login.html

Enter the credentials to create Queue and the user (By default username=admin and password=passw0rd)

The IBM MQ web console page looks as below,
image-20220822185038-12
To publish/subscribe to a message in the queue requires
  • A Queue - a named destination to which messages can be sent
  • A Topic name and a Topic string - subject of the information that is published in a publish/subscribe message.
  • A subscription - can receive messages, about the same or different topics, from more than one publisher
Create Queue
Click Manage QM1Creat.
image-20220822191036-1
Select Local.
image-20220822191104-2
Provide the Queue name  and click Create.
image-20220822191146-3
Now, the User can see the Queue in the Queue List.
image-20220822191207-4
Note: The user needs sufficient authorization to provide sufficient access to the queue.
Provide access to the user:
Navigate to MQCHECK Actions View Configuration.
image-20220822194928-1
Under Security, add the username, provide appropriate access and click Add.
image 12768
The user “app“ will be created and listed in the records.
image-20220822195406-2
Create Topic and topic string:
Navigate to Topics → Create.
image 12770
Select Quick create → Provide Topic name and Topic stringCreate.
image-20220822195723-3
The Topic and Topic string are created and listed. To use this, user must provide enough admin access to the Topic string.
To provide access, click Settings.
image-20220822200234-4
Under Security, add the username provided while creating Queue, provide appropriate access and click Add.
The user “app“ will be created and listed in the records.
image-20220822200825-5
Create a Subscription:
JMS client provides a subscription name and topic string, then IBM MQ creates a managed subscription using that name. So, users need not create a subscription. For more details, refer to the 4th link in the reference section.
Navigate to the client URL link
Link: http://<External IP address of client container>:<port>/MQConsumer/MainHandler-en_US.html
Example: http://20.85.144.53:8081/MQConsumer/MainHandler-en_US.html
The URL link will appear as below.
image 12771
Publishing a message:
Publishers and publications
 In IBM MQ publish/subscribe, a publisher is an application that makes information about a specified topic available to a queue manager in the form of a standard IBM MQ message called a publication. A publisher can publish information of more than one topic.
image 12772
Note: Before publishing the message, click on the “subscribe” button so that a subscription gets created on the MQ web console. 
Scenario:
News related to the sport will be published on the queue. Enter the text and click on the “Publish” icon. The message will be added to the queue.
Client console:
Once the message gets published, the status will appear as shown below.
image 12773
Service console:
To see the updates in the service console, open the Azure cloud shell and Enter the below commands.
  • kubectl get pods
  • kubectl logs <service pod name>
image 12781
MQ web console:
The message will be published to the Queue as well as to the subscription 
 
image 12782
image 12783
Subscribing a message:
The same message will be subscribed from Queue and displayed once the user click Subscribe icon.
Client console:
The status of the message gets updated and appears as shown below.
image 12784
Service console:
To see the updates in the service console, open the Azure cloud shell and Enter the below commands.
  • kubectl get pods
  • kubectl logs <service pod name>
image 12785
MQ Web Console:
The message will remain in the queue but disappears from the subscription.
image 12786
Conclusion:
This whitepaper covered the below topics
  • Flow chart of working model
  • Steps to create a sample application
  • Creating docker images on the Ubuntu terminal
  • Deploying the application on the Azure cloud
  • Running the containers
  • MQ Publish and subscribe
References:
Attachments:

[{"Type":"MASTER","Line of Business":{"code":"LOB35","label":"Mainframe SW"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSMQ79","label":"Rational Business Developer"},"ARM Category":[{"code":"a8m0z0000000BB1AAM","label":"Rational Business Developer"}],"ARM Case Number":"","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"9.7.0"}]

Document Information

Modified date:
13 October 2022

UID

ibm16612681