How much Java should I learn to work with microservices

 

Before starting about java microservices let begin by the concept of microservices.

 

In modern world of programming microservices are used to overcome the underlying problem monoliths architecture.

What is monoliths architecture

 

Monoliths architecture is where an application is developed as a one large system the application developed in this architecture are tightly coupled (everything depend on each other) making it difficult for independent scaling or code maintainability.

 

Let us we want to change a piece of code it will be difficult to change because since all modules or code is tightly coupled between them even a small change can also lead to Serious problem or application crack.

 

Now what is microservices architecture

 

microservices architecture is where a large application is divided into several small piece of modules which are which are independent from each other. A microservices-based application is a distributed system running on multiple processes or services (server or host)

 

In this doing changes in modules will be easy compared to monoliths since the modules are less coupled.

 

So we got a clear image about microservices architecture now how much java do I need to know to develop a microservices basically to work with microservices at least you need to know core java and servlet concept.

 

is java good for microservices


I hope that java is really a good language to develop microservices because java has lot of framework and library that helps in building microservices. Example spring boot, jersey is used to create microservices in java.

 

what is java microservices framework

 

Spring boot: This framework is used by lot of MNC are using spring boot to create microservices because spring boot application are production ready and its lot of build in library to support serval functionality such as caching, Message service etc. which are mostly used in microservices. Most important spring boot application are loosely coupled.

 

Jersey: This open-source framework supports JAX-RS APIs in Java is very easy to use.

 

Swagger: This is not a framework but it’s really very helpful in documenting API as well as gives you a development portal, which allows users to test your APIs also we can generate code out of swagger which save lot of time. Swagger editor which is online service by swagger hub where we can swagger representing our microservice.

 

how java microservices communicate with each other

 

Microservices communicate using HTTP protocol by which request and response are send and receive between them like a client server model where one who send the request is the client and one who send back the response for response is server. A request and response may contain xml or JSON.


Basically there are two type of communication that can happen.

 

Synchronous protocol. HTTP is a synchronous protocol. The client sends a request and waits for a response from the service.

The client code execution that could be synchronous (execution is blocked or will be wait until the response come) or asynchronous (code execution isn't blocked, and the response will reach a call back eventually).

The important point here is that the protocol (HTTP/HTTPS) is synchronous and the client code can only continue its task when it receives the server response.

 

Asynchronous protocol. Other protocols like AMQP use asynchronous messages. The client code or message sender usually doesn't wait for a response. It just sends the message as when sending a message to a RabbitMQ queue or any other message broker. 


how to create java microservice


Now let us see how we can create a microservices using java spring boot framework check the How to create spring boot project for microservice.

Post a Comment

Previous Post Next Post

Recent Posts

Facebook