Skip to content

Commit

Permalink
update try what you'll build
Browse files Browse the repository at this point in the history
  • Loading branch information
siwany committed Jun 17, 2024
1 parent 436d65e commit e68812b
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@ You'll also explore the configuration and use of Liberty Messaging Server, along

In this guide, you will use Jakarta Messaging APIs to build the application and implement a messaging solution that enables communication between different parts of Java microservices. Jakarta Messaging makes it easy to write and configure your application to send, receive, and process the events efficiently.

*What is Jakarta Messaging ?*
*What is Jakarta Messaging?*

Jakarta Messaging provides an easy way to asynchronously send, receive, and process messages that are received as continuous streams of events. By integrating Jakarta Messaging with Open Liberty, you can easily configure and manage message producers and consumers within your Java microservices. You simply use the Jakarta Messaging API to annotate methods in your application beans, and Open Liberty handles the communication infrastructure, ensuring messages are reliably exchanged. This integration allows your services to connect easily with external messaging systems, such as IBM MQ.

The application in this guide consists of two microservices, `system` and `inventory`. Every 15 seconds, the `system` microservice calculates and publishes an event that contains its current average system load. The `inventory` microservice subscribes to that information so that it can keep an updated list of all the systems and their current system loads. The current inventory of systems can be accessed via the `/systems` REST endpoint. You'll create the `system` and `inventory` microservices using Java Message System.

image::architecture.png[Application architecture where system and inventory services use the Jakarta Messaging to communicate.,align="center"]

ifdef::docker[]
== Additional prerequisites
* If you won't be working on the *Using IBM MQ* section, you don’t need to run Docker and you can skip this part.
* IBM MQ container is required to run if you are using Linux.

Before you begin, you need to install Docker if it is not already installed. For installation instructions, refer to the https://docs.docker.com/get-docker/[official Docker documentation^]. You will build and run the application in Docker containers.

Make sure to start your Docker daemon before you proceed.
endif::docker[]
// =================================================================================================
// Getting started
// =================================================================================================
Expand All @@ -60,8 +61,6 @@ include::{common-includes}/gitclone.adoc[]

The `finish` directory in the root of this guide contains the finished application. Give it a try before you proceed.

To try out the test, first go to the `finish` directory and run the following Maven goal that builds the application, starts the containers, runs the tests, and then stops the containers:

To try out the application, first go to the `finish` directory and run the following Maven goal to build and install the `models` module.
```
cd finish
Expand All @@ -78,28 +77,39 @@ Next, open another command-line session, navigate to the `finish` directory, and
mvn -pl system liberty:run
```

After you see the following message, your Liberty instance is ready:
After you see the following message, your Liberty instances are ready:
[role="no_copy"]
----
The defaultServer server is ready to run a smarter planet.
----

Then, visit the http://localhost:9080/health[http://localhost:9080/health^] URL to see the overall health status of the application, as well as the aggregated data of the startup, liveness and readiness checks. Three checks show the state of the `system` service, and the other three checks show the state of the `inventory` service. As you might expect, all services are in the `UP` state, and the overall health status of the application is in the `UP` state.
Visit the http://localhost:9085/health[^] URL to confirm that the `inventory` microservice is up and running.

When both the liveness and readiness health checks are up, go to the http://localhost:9085/inventory/systems[^] URL to access the `inventory` microservice. You see the CPU systemLoad property for all the systems:

Also, the `system` and `inventory` services can be found at the following URLs:
[source, role='no_copy']
----
{
"hostname":<your hostname>,
"systemLoad":2.25927734375
}
----

* http://localhost:9080/inventory/systems[http://localhost:9080/inventory/systems^]
You can revisit the http://localhost:9085/inventory/systems[^] URL after a while, and you will notice the CPU `systemLoad` property for the systems changed.

You can also use `curl` command to retrieve the hostname and systemLoad information from the inventory/systems server endpoint in another command line session:
You can also use `curl` command to retrieve the hostname and systemLoad information from the `inventory/systems` server endpoint in another command line session:
```
curl http://localhost:9085/inventory/systems
```

After you see the following message in the command-line session, both your services can reach the inventory/system server using the curl command.
After you see the following message in the command-line session, both your services can reach the `inventory/system` server using the curl command.

[role="no_copy"]
----
[{"hostname": your hostname,"systemLoad": current systemLoad value}]
{
"hostname": <your hostname>,
"systemLoad": 2.25927734375
}
----

After you are finished checking out the application, stop the Liberty instance by pressing `CTRL+C` in each command-line sessions where you ran Liberty. Alternatively, you can run the `liberty:stop` goal from the `finish` directory in another shell session:
Expand Down

0 comments on commit e68812b

Please sign in to comment.