[DOCKER] I tried to modernize a Java EE application with OpenShift.


Contributed an article on "Modernization of Java EE Applications with OpenShift" using "Red Hat OpenShift on IBM Cloud", a managed service of IBM Cloud OpenShift. https://www.atmarkit.co.jp/ait/articles/1911/15/news002.html

The "Red Hat OpenShift on IBM Cloud" used in that article is a paid service, so I think it's difficult for many people to try the steps in the article. Therefore, ** Using MiniShift, which can be used for free, we rewrote it so that you can easily experience the modernization of Java EE applications with OpenShift. ** **

** This time, I would like to try the case where both the application and database are containerized. Those who read the article will be able to learn about the cooperation of multiple containers (application and database connection) in addition to the content of the article. ** In the article, the database used IBM Cloud's managed service "Compose for MySQL". example-health-archtecture-0.png

We have made a series from (1) to (5).

-(This post) "I tried to modernize a Java EE application with OpenShift"-Java EE application running on Open Liberty for business logic Modernization

-"I tried to modernize Java EE application by OpenShift (2)"-Modernization of Node.js application of UI (user interface) for patients

-"I tried to modernize Java EE application by OpenShift (3)"-Modernization of PHP application function addition for health record manager

-"I tried to modernize Java EE application with OpenShift (4)"-DevOps and CI / CD using only standard OpenShift functions (Continuous integration / continuous delivery)

-"I tried to modernize Java EE application with OpenShift (5)"-DevOps and CI / CD (continuous integration / continuation) using Jenkins Delivery)

Modernization of Java EE applications with OpenShift

In IBM Code Patterns (https://developer.ibm.com/jp/patterns/), "Deploy microservices within a fictitious medical app using Java EE and OpenLiberty There is a code pattern called ".ibm.com/jp/patterns/jee-app-modernization-with-openshift/)". From now on, I would like to use this code pattern to actually move my hands and experience the modernization of Java EE applications. It's easy to imagine that this series of steps corresponds to the procedure for migrating from an on-premises system to the cloud. From now on, let's become a solution architect and experience the modernization journey that will spread in the cloud.

Example Health use case

Example Health is a fictitious medical company. The company has a long history and has hundreds of thousands of patient records. Originally, Example Health used a monolithic application structure for its applications. Their application structure was a full-stack Java application running on WebSphere connected to a Db2 database on a mainframe. The original architecture of Example Health is: example-health-archtecture-1.png Recently, Example Health decided to modernize the application and split it into microservices. They decided to move to a SQL database (MySQL) connected to a Java EE application running in Open Liberty for business logic and a Node.js application for the patient UI. In addition, Example Health has decided to containerize all of these applications and SQL databases and run them on Red Hat OpenShift on IBM Cloud. The new architecture of Example Health is as follows: example-health-archtecture-3.png

As a result of the move to Red Hat OpenShift on IBM Cloud, Example Health is now easily extensible. Soon, new microservices will be included, including health record management and analytics applications.

-Health record management application -Analysis Application

Preparing for MiniShift

Please prepare MiniShift by referring to another post by Qiita.

Note: Please install Docker version 17.09 or later on the host that launches MiniShift. It's a good idea to install the latest version of Docker CE (Community Edition). This is because the Dockerfile that we will use later uses the syntax to change the owner of the file with the ADD / COPY --chown flag, which is supported from Docker 17.09. The version of Docker that runs on the MiniShift virtual machine (VM) is 1.13, so it is troublesome. By the way, if you do not use the --chown flag in the Dockerfile, you can avoid it from being awkward, but this time we will do it without changing the resource of the code pattern.

-Install OpenShift (MiniShift) on CentOS 7 on ESXi

-Official site-https://docs.okd.io/latest/minishift/getting-started/installing.html

MiniShift is not used in the first half of the procedure. Stop MiniShift until you need it.

# minishift stop

If you are running the "# eval $ (minishift docker-env)" command after launching MiniShift, When you "docker push", register the image in Docker running in the MiniShift virtual machine (VM).


This time, I want to register the image in Docker of the host that starts MiniShift of the work host, so if the values are entered in DOCKER_HOST, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH by executing the "# env | grep DOCKER" command, use the following command to create the environment. Empty the variable.

export DOCKER_HOST=""


(Environment I tried) CentOS 7.7 Minimum configuration

1. Maven (JDK is also installed as a Maven dependency)

# yum install maven

2. Confirmation of starting Docker daemon

I will build Docker later, so make sure that the daemon is running on Docker

# systemctl status docker

In Dockerfile, the syntax to change the owner of the file with ADD / COPY --chown supported from Docker 17.09 is used, so Docker supported by CentOS will cause an error because the syntax is unknown. Avoid making the Docker version 17.09 or higher, or processing the Dockerfile with the chown command on a separate line (separate layer) for the --chown part.

3. Clone the GitHub project. Clone will create an example-health-jee-openshift folder.

# git clone https://github.com/daihiraoka/example-health-jee-openshift.git
Cloning into 'example-health-jee-openshift'...
remote: Enumerating objects: 263, done.
remote: Counting objects: 100% (263/263), done.
remote: Compressing objects: 100% (175/175), done.
remote: Total 263 (delta 108), reused 204 (delta 53), pack-reused 0
Receiving objects: 100% (263/263), 17.82 MiB | 5.57 MiB/s, done.
Resolving deltas: 100% (108/108), done.
# cd example-health-jee-openshift
# ls
example-health-api  generate  LICENSE  readme_images  README.md  screenshots

4. Build the Java EE application.

# cd example-health-api/
# mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building health-api 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom (7 KB at 7.4 KB/sec)
[INFO] Building war: /root/example-health-jee-openshift/example-health-api/target/health-api.war
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.656s
[INFO] Finished at: Thu Oct 17 13:58:55 JST 2019
[INFO] Final Memory: 14M/143M
[INFO] ------------------------------------------------------------------------

5. Build the Docker image for your Java EE application.

# docker build -t ol-example-health:1 .
Sending build context to Docker daemon  13.48MB
Step 1/10 : FROM openliberty/open-liberty:javaee8-ubi-min
javaee8-ubi-min: Pulling from openliberty/open-liberty
bdb299bbb0dd: Pull complete 
22b1a8fa1ec0: Pull complete 
bccea9526f92: Pull complete 
ca821998be76: Pull complete 
7d738fac7181: Pull complete 
2356e9fc5285: Pull complete 
048ba391e9fe: Pull complete 
347eb7134a38: Pull complete 
94456b65cdbb: Pull complete 
Digest: sha256:1f08f83c3076aaec7a7d3639864ca06998a779cecad6ad1452d501008c56f63b
Status: Downloaded newer image for openliberty/open-liberty:javaee8-ubi-min
 ---> fc55e2d66c27
Step 2/10 : ENV INSTALL_DIR /opt/ol/wlp/
 ---> Running in 45aaeaaa0c92
Removing intermediate container 45aaeaaa0c92
 ---> 27fe222d05be
Step 3/10 : ENV CONFIG_DIR /opt/ol/wlp/usr/servers/defaultServer/
 ---> Running in 395e839afb7f
Removing intermediate container 395e839afb7f
 ---> 8632cfb62026
Step 4/10 : ADD --chown=default:root https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.16/mysql-connector-java-8.0.16.jar  ${INSTALL_DIR}lib/mysql-connector-java-8.0.16.jar
Downloading [==================================================>]  2.293MB/2.293MB

 ---> 61898c26bdb1
Step 5/10 : RUN chmod 644 ${INSTALL_DIR}lib/mysql-connector-java-8.0.16.jar
 ---> Running in 8011b3b50bac
Removing intermediate container 8011b3b50bac
 ---> 5909218a689a
Step 6/10 : COPY liberty-mysql/mysql-driver.xml ${CONFIG_DIR}configDropins/defaults/
 ---> f42f5684e5b0
Step 7/10 : COPY liberty/server.xml $CONFIG_DIR
 ---> 67938badab11
Step 8/10 : COPY liberty/jvm.options $CONFIG_DIR
 ---> 60c3c494f5ef
Step 9/10 : COPY target/health-api.war /opt/ol/wlp/usr/servers/defaultServer/apps
 ---> 1bcb2f837df9
Step 10/10 : EXPOSE 9080
 ---> Running in eba84e894ddc
Removing intermediate container eba84e894ddc
 ---> aa91da14cf12
Successfully built aa91da14cf12
Successfully tagged ol-example-health:1

6. If the Docker build is successful, the base image openliberty / open-liberty and the ol-example-health image created this time will be output.

# docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
ol-example-health          1                   aa91da14cf12        48 seconds ago      348MB
openliberty/open-liberty   javaee8-ubi-min     fc55e2d66c27        16 hours ago        343MB

Note: RHEL7 of Red Hat UBI (Red Hat Universal Base Image) is used for the base image of Open Liberty specified in the FROM clause of the Dockerfile. Red Hat UBI is a container image provided through Red Hat quality control and can be freely redistributed for free. Container images created based on Red Hat UBI can be supported when running on Red Hat OpenShift on IBM Cloud. In an environment that does not use OpenShift, support is not available, but there is an advantage that RHEL container images can be used free of charge. If you are operating a container in a company, you may need to judge whether it is safe to give a container of unknown origin such as CentOS or Ubuntu from each department. However, I had no choice but to use it for various reasons, and sometimes I was worried about using it. With Red Hat UBI, that worry is eliminated because it is provided after the quality control of Red Hat. If you are currently using a CentOS or Ubuntu container image, why not try Red Hat UBI?

Red Hat UBI(Red Hat Universal Base Image) https://access.redhat.com/containers/#/search/ubi

7. Register the Docker image "ol-example-health" of the Java EE application in Docker Hub.

--Please create a Docker Hub account in advance. --Replace daihiraoka with your Docker Hub account name and execute.

Tag the ol-example-health image in the format "Docker Hub account name / image name: tag name".

# docker tag ol-example-health:1 daihiraoka/ol-example-health:1

If you output the list of Docker images, you can see that the daihiraoka / ol-example-health image has been created.

# docker images
REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
daihiraoka/ol-example-health   1                   901666e26ca5        27 minutes ago      450MB
ol-example-health              1                   901666e26ca5        27 minutes ago      450MB
openliberty/open-liberty       javaee8-ubi-min     bb992680821b        17 hours ago        445MB

Log in to Docker Hub and register the daihiraoka / ol-example-health image in the Docker Hub repository.

# docker login -u daihiraoka
Login Succeeded

# docker push daihiraoka/ol-example-health:1

When the image registration is completed, daihiraoka / ol-example-health will be displayed in the Docker Hub repository. dockerhub-01.png

This time I used Docker Hub in the Code Patterns procedure, but IBM Cloud has a Container Registry service. For commercial use, IBM Cloud Container Registry is typically used to manage container images.

· Overview of IBM Cloud Container Registry

8. Launch MiniShift

# minishift start
-- Starting profile 'minishift'
-- Check if deprecated options are used ... OK
-- Checking if https://github.com is reachable ... OK
-- Checking if requested OpenShift version 'v3.11.0' is valid ... OK
-- Checking if requested OpenShift version 'v3.11.0' is supported ... OK
-- Checking if requested hypervisor 'kvm' is supported on this platform ... OK
Server Information ...
OpenShift server started.
<img width="400" alt="dockerhub-01.png " src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/209170/d24a8d74-9aca-898e-1066-86395168ba48.png ">

The server is accessible via web console at:

--Applying MiniShift environment variables

# eval $(minishift oc-env)    <-PATH definition of oc command
# eval $(minishift docker-env) <-Setting up a connection to Docker running on a MiniShift VM
# source <(oc completion bash) <-Shell completion of commands and resources

When I try to execute minishift oc-env, the command is output because it passes through the PATH of the oc command.

# minishift oc-env
export PATH="/root/.minishift/cache/oc/v3.11.0/linux:$PATH"
# Run this command to configure your shell:
# eval $(minishift oc-env)

# ls -1 /root/.minishift/cache/oc/v3.11.0/linux

When minishift docker-env is executed, the connection information to Docker running on the MiniShift VM running on the KVM is output as shown below. By defining this environment variable, the container image will be handled in the Docker registry of the MiniShift VM instead of the local Docker registry.

# minishift docker-env
export DOCKER_HOST="tcp://"
export DOCKER_CERT_PATH="/root/.minishift/certs"

9. Log in to the OpenShift CLI with your username as a developer.

(In MiniShift, any password can be used, so use any character string.)

# oc login -u developer
Logged into "" as "developer" using existing credentials.

You have one project on this server: "myproject"

Using project "myproject".

10. Create a project for Example Health.

This will create a new project and set the pod (container) as the working project to be deployed.

# oc new-project health
Now using project "health" on server "".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git

to build a new example application in Ruby.

11. Print a list of ImageStream (is) for your OpenShift project to find the MySQL catalog.

# oc get is -n openshift
NAME         DOCKER REPO                            TAGS                         UPDATED
dotnet       2.0,latest                   16 hours ago
httpd        2.4,latest                   16 hours ago
jenkins      2,latest,1                   16 hours ago
mariadb      10.1,10.2,latest             16 hours ago
mongodb      2.6,3.2,3.4 + 3 more...      16 hours ago
mysql        latest,5.5,5.6 + 1 more...   16 hours ago
nginx        1.10,1.12,1.8 + 1 more...    16 hours ago
nodejs       4,6,8 + 4 more...            16 hours ago
perl         5.20,5.24,5.26 + 2 more...   16 hours ago
php          7.1,latest,5.5 + 2 more...   16 hours ago
postgresql   9.4,9.5,9.6 + 3 more...      16 hours ago
python       3.5,3.6,latest + 3 more...   16 hours ago
redis        3.2,latest                   16 hours ago
ruby         2.2,2.3,2.4 + 3 more...      16 hours ago
wildfly      11.0,12.0,13.0 + 5 more...   16 hours ago

ImageStream of the container image used by mysql this time. The nodejs and dotnet displayed in the list are the same as the catalog of the Web console in the image below. OpenShift provides a mechanism for easily deploying applications using the CLI.


12. Create a container for your MySQL database using OpenShift's S2I (Source to Image).

# oc new-app \
-e MYSQL_USER=admin \
-e MYSQL_PASSWORD=password \
-e MYSQL_DATABASE=health \
--name=mysql \

Define the environment variable with "-e".

parameter Overview
-e MYSQL_USER MySQL username
-e MYSQL_DATABASE Database name
--name Container name
openshift/mysql:5.7 openshift/mysql:5.7 is the ImageStream name of the base container image(openshift project mysql:5.7)
~https://github.com(abridgement) ~(tilde)Specify the source code repository on the right side between

This time, I'm omitting the persistent storage that stores the data in the database. If the persistent storage is not set in the pod (container), all the registered data will be deleted when the pod (container) is stopped. In this case, when a new pod (container) is started, it is empty and you have to restart from importing the SQL schema.

Execution result

--> Found image f83a293 (6 days old) in image stream "openshift/mysql" under tag "5.7" for "openshift/mysql:5.7"

    MySQL 5.7 
    MySQL is a multi-user, multi-threaded SQL database server. The container image provides a containerized packaging of the MySQL mysqld daemon and client application. The mysqld server daemon accepts connections from clients and provides access to content from MySQL databases on behalf of the clients.

    Tags: database, mysql, mysql57, rh-mysql57

    * A source build using source code from https://github.com/daihiraoka/example-health-jee-openshift.git will be created
      * The resulting image will be pushed to image stream tag "mysql:latest"
      * Use 'start-build' to trigger a new build
    * This image will be deployed in deployment config "mysql"
    * Port 3306/tcp will be load balanced by service "mysql"
      * Other containers can access this service through the hostname "mysql"

--> Creating resources ...
    imagestream.image.openshift.io "mysql" created
    buildconfig.build.openshift.io "mysql" created
    deploymentconfig.apps.openshift.io "mysql" created
    service "mysql" created
--> Success
    Build scheduled, use 'oc logs -f bc/mysql' to track its progress.
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose svc/mysql' 
    Run 'oc status' to view your app.

After a while, the mysql pod [mysql-1-hktv2] will start.

# oc get pod
NAME            READY     STATUS      RESTARTS   AGE
mysql-1-build   0/1       Completed   0          3m
mysql-1-hktv2   1/1       Running     0          2m

13. Create a database schema in the MySQL container

Log in to the container with the oc rsh command to create the database schema in MySQL.

# oc rsh mysql-1-hktv2

If you log in with rsh, you can see on github that the directory structure is inside the container.

sh-4.2$ ls
LICENSE  README.md  example-health-api	generate  readme_images  screenshots

Import the SQL schema of patient health record data Filename: example-health-api / samples / health_schema.sql

sh-4.2$ mysql -u admin -ppassword health < ./example-health-api/samples/health_schema.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.

Outputs a list of health database tables. If the SQL schema import is completed normally, the output result table will be displayed.

sh-4.2$ mysql -u admin -ppassword health -e "show tables;"
mysql: [Warning] Using a password on the command line interface can be insecure.
| Tables_in_health |
| Allergies        |
| Appointments     |
| MESSAGE          |
| Observations     |
| Organizations    |
| Patients         |
| Prescriptions    |
| Providers        |
| SEQUENCE         |

Now that the database has been created, exit the container with the "exit" command.

sh-4.2$ exit

14. Java EE application for business logic and MySQL container-to-container communication settings

Go back to your working host and type "pwd" and you should be in the "example-health-jee-openshift / example-health-api" folder.

# pwd
# ls
create-secrets.sh  Dockerfile  kubernetes-openshift.yaml  liberty  liberty-mysql  pom.xml  samples  src  target

To connect MySQL with a Java EE application for business logic, first look up the MySQL service name.

# oc get svc
mysql     ClusterIP   <none>        3306/TCP   9m

Communication between pods is done by service name. Remember the service name as it will be used in the next step.

Use the example-health-api / create-secrets.sh script to set the MySQL connection information.

cat create-secrets.sh
oc create secret generic db-secrets    \
     --from-literal=db_username=admin        \
     --from-literal=db_password=password       \
#    --from-literal=db_host="jdbc:mysql://Service name:port number/Database name?sessionVariables=sql_mode=''"

Note: As of October 2019, create-secrets.sh has a "/" between "DB name /? SessionVariables" and "DB name" and "?". When connecting with JDBC, a connection error will occur because "/" is also included in the DB name character string. Therefore, delete the "/".

In OpenShift, authentication information such as passwords is stored in an object called secrets, which has a mechanism for holding confidential information. And the connection information of MySQ is used as an environment variable in the pod (container). To use it as an environment variable, link the environment variable and secrets in the Deployment object that defines the deployment of the pod (container) in kubernetes-openshift.yaml in the next step.

--Excerpt from kubernetes-openshift.yaml that defines env (environment variable)

- name: ENV_MYSQL_UR
      name: db-secrets
      key: db_host
      name: db-secrets
      key: db_username
      name: db-secrets
      key: db_password

And the Open Liberty DataSource settings use the environment variables defined above to set the database connection parameters.

--Excerpt from example-health-api / liberty / server.xml that defines DataSource

<dataSource id="DefaultDataSource" jndiName="jdbc/health-api" jdbcDriverRef="mysql-driver"
           type="javax.sql.ConnectionPoolDataSource" transactional="true">

   <properties url="${ENV_MYSQL_URL}"

Note: There is an undefined environment variable: ENV_MYSQL_DB_NAME above, because the database name is defined in the environment variable: ENV_MYSQL_URL. Here, the original Code Patterns code is displayed as it is.

Run the script to create secrets in OpenShift. After creating it, if you output the list of secrets with the "oc get secrets" command, you can see that it is created with the name "db-secrets".

#  ./create-secrets.sh 
secret/db-secrets created

# oc get secrets
NAME                       TYPE                                  DATA      AGE
db-secrets                 Opaque                                3         2d

15. Deploy Java EE application

Edit the file: example-health-api / kubernetes-openshift.yaml and change the image key in the containers section to the Docker image for your Java EE application pushed to Docker Hub. --Replace daihiraoka with your Docker Hub account name. --Replace the tag for ol-example-health from latest to 1.

(Change before)

  - name: example-health-api
    image: ykoyfman/ol-example-health:latest

(After change)

  - name: example-health-api
    image: daihiraoka/ol-example-health:1

Deploy the Java EE application to the cluster.

# oc create -f kubernetes-openshift.yaml
service/example-health-api created
deployment.apps/example-health-api created

In example-health-api / kubernetes-openshift.yaml, the definition for deploying Open Liberty pod (container) is described. Deployment, Access the End Point (IP) of Open Liberty pod (container) Service to do is described. By running this yaml, OpenShift will launch an Open Liberty pod (container) and you will be able to connect to the Open Liberty pod (container) using Service.

After a while, the Open Liberty pod (container) will start. When you execute the "oc get pod" command to output a list of pods (containers), the STATUS of the pods (containers) of "example-health-api- " becomes "Running".

# oc get pod
NAME                                  READY     STATUS      RESTARTS   AGE
example-health-api-7fcb786fb6-l5kx9   1/1       Running     0          1m
mysql-1-build                         0/1       Completed   0          22m
mysql-1-hktv2                         1/1       Running     0          21m

16. Create Route, an OpenShift object for publishing Java EE applications to the Internet.

# oc expose svc example-health-api
route.route.openshift.io/example-health-api exposed

Make sure your Java EE application is working. First, get the host name assigned to Route.

# oc get route
NAME                 HOST/PORT                                         PATH      SERVICES             PORT      TERMINATION   WILDCARD
example-health-api   example-health-api-health.             example-health-api   http                    None

In this case, the first NAME example-health-api is the Route name and the next HOST / PORT FQDN is the generated host name. When Route is accessed, the IP address of the EndPoint of the Open Liberty pod (container) is accessed through the example-health-api of SERVICES.

17. Check the operation of Java EE application in the browser

In a browser window, go to / openapi / ui /. Shows the OpenAPI endpoints and specifications supported by Java EE applications. Example) http://example-health-api-health.

スクリーンショット 2019-10-17 14.52.39.png

Business Logic is now launched on Red Hat OpenShift on IBM Cloud. At the moment the database has a SQL schema created but no data. In the following procedure, the USER registers the patient's health record test data using the REST API through the route ①. business-logic-architecture.png

18. Preparation of patient health record test data generation program

--Patient health record Create test data Execute generate.sh to register the test data in MySQL with REST API. In generate.sh, you can output synthetic realistic (but not real) patient data and related health records in various formats [synthea](https://github.com/synthetichealth/synthea] A program called) is used.

--Script name: example-health-jee-openshift / generate / generate.sh

--Install the Node.js csvtojson needed to run generate.sh.

# ls
example-health-api  generate  LICENSE  readme_images  README.md  screenshots
# cd generate/
# ls
generate.sh  package.json  README.md
# pwd
# yum install npm
 npm                      x86_64                   1:3.10.10-                    epel                   2.5 M
Installing for dependencies:
 libuv                    x86_64                   1:1.30.1-1.el7                              epel                   138 k
 nodejs                   x86_64                   1:6.17.1-1.el7                              epel                   4.7 M
# npm install csvtojson
[email protected] /root/example-health-jee-openshift/generate
└─┬ [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  └─┬ [email protected] 
    └── [email protected] 

# pwd

-Pass the PATH so that csvtojson can be used.
# PATH=$PATH:/root/example-health-jee-openshift/generate/node_modules/csvtojson/bin

19. Change Route default timeout value

Change the default timeout value for the Route name: example-health-api created in the previous step to 60 minutes. When the USER executes generate.sh, it calls the Open Liberty pod (container) with the REST API through the router of OpenShift's application load balancer (ALB). Since the default timeout of OpenShift router is 30 seconds, the default value is too short for long-running REST API calls such as inputting test data, so it is necessary to set a long timeout value.

# oc annotate route example-health-api --overwrite haproxy.router.openshift.io/timeout=60m
  route.route.openshift.io/example-api annotated

You can check the result of the change with the "oc describe route " command.

# oc describe route example-health-api 
Name:			example-health-api
Namespace:		health
Created:		13 minutes ago
Labels:			app=example-health-api
Annotations:		haproxy.router.openshift.io/timeout=60m
Requested Host:		example-health-api-health.
			  exposed on router router 13 minutes ago
Path:			<none>
TLS Termination:	<none>
Insecure Policy:	<none>
Endpoint Port:		http

Service:	example-health-api
Weight:		100 (100%)

20. Running the patient's health record test data program

Let's do it. The options in generate.sh are -p for population and -u for the host name exposed on route. This time, we will register the data of 150 people.

# ./generate.sh -p 150 -u http://example-health-api-health.
Cloning into 'synthea'...
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 31698 (delta 7), reused 21 (delta 2), pack-reused 31660
Receiving objects: 100% (31698/31698), 605.79 MiB | 9.81 MiB/s, done.
Resolving deltas: 100% (18183/18183), done.
Checking out files: 100% (663/663), done.

4 actionable tasks: 2 executed, 2 up-to-date

It took only a few minutes from the time BUILD SUCCESSFUL was displayed until the registration was completed. If you want to check the status on the way, check the log of Open Liberty's pod (container) by executing the "oc logs -f example-health-api- " command.

21. Confirmation of registered patient health record data

Use the API "/ resources / v1 / getInfo / patients" to get a list of patients and check if the patient's health record data is registered. If you specify the host name / resources / v1 / getInfo / patients in the URL with curl and execute it, you can get the data of 150 patients, which is the same as the number registered in advance.

# curl -X GET "http://example-health-api-health." -H "accept: */*"
{"ResultSet Output":[{"CA_DOB":"1962-10-
09","CA_FIRST_NAME":"Sergio","CA_GENDER":"M","CA_LAST_NAME":"Castellanos"},{"CA_DOB":"1988-06-06","CA_FIRST_NAME":"Lorraine","CA_GENDER":"F","CA_LAST_NAME":"Ledner"},{"CA_DOB":"2018-01-29","CA_FIRST_NAME":"Shemika","CA_GENDER":"F","CA_LAST_NAME":"Terry"},{"CA_DOB":"1954-03-26","CA_FIRST_NAME":"Clyde","CA_GENDER":"M","CA_LAST_NAME":"Ferry"},{"CA_DOB":"1946-03-25","CA_FIRST_NAME":"Bobby","CA_GENDER":"M","CA_LAST_NAME":"Krajcik"}],"StatusCode":200,"StatusDescription":"Execution Successful"}

22. Summary

Example Health has now successfully split the business logic part from the monolithic Java EE application structure and run it as a Java EE application for business logic running on Open Liberty running on OpenShift in MiniShift. You can also use the patient health test data generator (generater.sh) to actually populate the MySQL database with patient health test data using the REST API and access that data from a Java EE application. Is done.

It seems that the modernization journey has been completed by the steps up to this point, but as it is, it is not sufficient as a service because it can only be handled by the REST API. From the next step, I would like to deploy another patient UI Node.js application split from the monolithic Java EE application to OpenShift and combine it with the Java EE application for business logic I created this time.

The continuation follows the post of "I tried to modernize Java EE application by OpenShift (2)".

Recommended Posts

I tried to modernize a Java EE application with OpenShift.
I tried to break a block with java (1)
I tried to interact with Java
I tried to create a java8 development environment with Chocolatey
[Azure] I tried to create a Java application for free ~ Connect with FTP ~ [Beginner]
I tried to make an Android application with MVC now (Java)
I tried to make Basic authentication with Java
java I tried to break a simple block
[iOS] I tried to make a processing application like Instagram with Swift
I tried to build a Firebase application development environment with Docker in 2020
I want to create a dark web SNS with Jakarta EE 8 with Java 11
I tried to make a talk application in Java using AI "A3RT"
I tried to implement TCP / IP + BIO with JAVA
[Java 11] I tried to execute Java without compiling with javac
I tried to create a Clova skill in Java
I tried to make a login function in Java
I tried using Log4j2 on a Java EE server
I tried OCR processing a PDF file with Java
I tried to implement Stalin sort with Java Collector
I tried to make a machine learning application with Dash (+ Docker) part3 ~ Practice ~
I built a Java EE environment on AWS and tried running a web application
[Java] I tried to connect using a connection pool with Servlet (tomcat) & MySQL & Java
I tried to clone a web application full of bugs with Spring Boot
[Azure] I tried to create a Java application for free-Web App creation- [Beginner]
I tried to create a shopping site administrator function / screen with Java and Spring
[Rails] I tried to create a mini app with FullCalendar
I want to make a list with kotlin and java!
I want to make a function with kotlin and java!
I tried UDP communication with Java
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I tried to convert a string to a LocalDate type in Java
I tried to summarize Java learning (1)
I tried to implement a buggy web application in Kotlin
I tried to make a client of RESAS-API in Java
I tried to create a padrino development environment with Docker
I tried to summarize Java 8 now
I tried OCR processing a PDF file with Java part2
A story that I struggled to challenge a competition professional with Java
I tried running a letter of credit transaction application with Corda 1
I tried to build a simple application using Dockder + Rails Scaffold
[Java] I tried to make a maze by the digging method ♪
I tried to make a group function (bulletin board) with Rails
I want to develop a web application!
I tried to summarize Java lambda expressions
One-JAR Java EE application with WebSphere Liberty
I tried to get started with WebAssembly
I tried playing with BottomNavigationView a little ①
I tried using OpenCV with Java + Tomcat
I tried to implement ModanShogi with Kinx
I tried to make a machine learning application with Dash (+ Docker) part2 ~ Basic way of writing Dash ~
I tried to make a simple face recognition Android application using OpenCV
I tried learning Java with a series that beginners can understand clearly
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (PowerMockito edition)
I tried to make a Web API that connects to DB with Quarkus
Java beginner tried to make a simple web application using Spring Boot
I want to ForEach an array with a Lambda expression in Java
I tried to verify AdoptOpenJDK 11 (11.0.2) with Docker image
I tried to manage struts configuration with Coggle
Connect to Aurora (MySQL) from a Java application
I tried to manage login information with JMX
I tried to develop a man-hour management tool