Sitemap

Why I decided to use Open Liberty

4 min readJul 3, 2022

--

This is the story of how I fell in love with open liberty.

Open Liberty

I want to essentially develop a new product as a web developer. For straightforward statistical reasons, I explained in my earlier article why I chose to create a product with flutter. That was the front end of my product, but what about the back end?
Micro-services-based backends are something I do enjoy. Here, I said it! However, there is one aspect of it that I don’t enjoy. It’s the beginning of designing a micro-service backend. You would be mistaken for believing that the only difference between microservices and traditional applications is the scale of the application when you first consider them. After all, it’s just a collection of tiny programs communicating with one another, right? You don’t understand how building, containerizing, deploying, and managing numerous interconnected applications reveals your own set of requirements unless you delve a little more and perhaps put it into reality. Only once you have completed each of these minuscule processes are you ready to design and launch your application.

Being an exceedingly lazy engineer, I choose to look at some additional tools rather than writing down and configuring all these procedures. I want to emphasize once more how much time I want to devote to product design rather than backend design. I then noticed open liberty!
So how did I come up to open liberty? It is pure luck and a lot of research. I think the biggest pain of creating microservices is not writing or coordinating. In a small application like mine that is the smallest problem that I might have. Probably the biggest problem that I am going to have is monitoring, logging, performance improvement, and continuous deployments. And it seems to be Open Liberty is the perfect tool to answer all my problems.
The next step is to write a small blog about the beginning of my journey about Open Liberty so here I am.
First of all, lets get a description from their website.

Open Liberty is an open application framework designed for the cloud. It’s small, lightweight, and designed with modern cloud-native application development in mind. It deploys to every major cloud platform, including Docker, Kubernetes, and Cloud Foundry.
Well, that’s not descriptive at all. Let’s start over!
Well, I think they should change this description from their website but here is mine,
Open Liberty is an open framework for the Java ecosystem that allows the development of microservices. The RESTful application that contains your system microservice runs in a server from its class file and other artifacts. Open liberty automatically monitors these artifacts; whenever they are updated, it updates the running server without needing to restarting it.
Yes IBM, this is a much better description.

So let’s get down to business and try this new tool.

First of all, I will create a super simple rest-API, which allows users to make crud operations. They already provide an easy way to create an application provided by this link https://openliberty.io/start/. But if you have your app already it is also pretty simple to configure your project.

Get Doga Budak’s stories in your inbox

Join Medium for free to get updates from this writer.

I will use the example project where you can download the zip file from the open liberties website.

@ApplicationPath("/api")
public class RestApplication extends Application {
}

Well, this demo project creates an endpoint called “/api”. We can set even more endpoints and more specifications to our little rest API but right now one endpoint will be sufficient.

@ApplicationPath("/api")public class RestApplication extends Application {
@GET
@Produces(MediaType.APPLICATION_JSON)
}

Here I specify the endpoint type ( It is a get) and what it returns (JSON). Now it is quite ready, we have a dumb get endpoint.
To get the service running, the Liberty server needs to be correctly configured

src/main/liberty/config/server.xml

The Server.xml file holds specific information regarding the server. I used the example configuration file which is given as an example on their website.

https://github.com/openliberty/guide-rest-intro.git

When you run Open Liberty in development mode, known as dev mode, the server listens for file changes and automatically recompiles and deploys your updates whenever you save a new change. Run the following goal to start Open Liberty in dev mode:

mvn liberty:dev

So, there you go from this point onwards your server will detect the changes you make and it will restart automatically. Monitoring and logging are also available with open liberty, on a next part I will also explain how to enable them.

Thanks for reading!

--

--