Posts

Showing posts with the label Spring

Creating first Jenkins pipeline: tutorial

Image
Jenkins uses a feature called Jenkins Pipeline which is a collection of jobs that brings the software from version control into the hands of the end-users by using automation tools. They represent multiple Jenkins jobs as one whole workflow in the form of a pipeline. In this blog, I am going to share my knowledge on how can we write multiple Jenkins jobs as a pipeline and it uses two different syntaxes i.e. Declarative and Scripted pipeline and i n our examples, we're going to use the Scripted Pipeline which is following a more imperative programming model built with Groovy. Prerequisite: Code on bitbucket/ GitHub Jenkins Installation Download required plugins to run pipelines like Pipeline, SonarQube Scanner, Check Style, Junit, Git Integration, Maven Integration. Sonar up and running.   Let’s start creating pipeline will do below tasks: Clone  Project from Jenkins Build and run Junit test cases Run Sonar Run Checkstyle Package it as a jar file ...

Streaming Spring boot logs to ELK stack

Image
In my previous blog , we have done ELK installation on windows 10 and we have even tried to push messages from input console to Elastic Search and finally viewed on Kibana Server. I will write a separate blog on why do we need ELK? In this blog, I’ll show you how can we push spring boot application log directly to Elastic search using Logstash which we can analyze on Kibana and If you don’t know how to install ELK on windows 10 then you can refer my previous blog and start Elastic Search and Kibana server. Prerequisite Elastic Search and Kibana running on your machine Basic knowledge of Spring boot application If you don’t want to start your application from scratch then you can download one spring boot application from my GitHub repository as well. I am assuming that the Elastic Search and Kibana server are running on your machine and you have a fair idea of how to start the Logstash server and what is Logstash conf file. So, to push spring boot logs cont...

How to create Docker Image and push java app in a Docker Engine

Image
In this blog, I am going to share my knowledge on the creation of a docker image and how can we run in a Docker Engine. Prerequisite Basic Knowledge of Docker Docker must be running on your machine. Good to aware of Spring boot application. I already have one spring boot application in my IntelliJ which expose one endpoint /users/{id}. We will see how can we push and run this application in a docker container.  We need to create one file named Dockerfile to add docker instruction (Check above image). Now go to Terminal and check whether the docker is running or not on your machine. Run docker build to create an image and push it to the container using the command. docker build -f Dockerfile -t docker-spring-ehcache . The above command will execute all the operations that we have mentioned in our Dockerfile like pulling OpenJDK 8 from the docker hub if not exist. Let's see if our image got pushed to docker containers or not by listing all d...

Spring Boot Tutorial

Prerequisite: Basic knowledge of Spring boot application I am working on a series of implementing frameworks with Spring boot application but not getting enough time to blog it and post it here or on my LinkedIn profile. So, I have started uploading my work on my GitHub repository from where it can be downloaded easily. I tried my best to add short notes for each annotation/configuration/properties in README and even I have uploaded a few screenshots to understand in a more better way. Try it out and Please do let me know in case of any confusion. Spring Boot Actuator Spring Boot Ehcache Spring Boot Swagger Spring Boot JPA Will keep uploading with others framework as well. Feedback is also most welcome. Thank you. Happy Learning!

MicroServices: Spring cloud ribbon with Discovery Server

Image
In this article, I am going to share my knowledge on Spring Cloud Ribbon and how can we use Ribbon with RestTemplate as well as with Feign Client. We will also see how Enabling discovery Sever will improve the scalability of Microservice. Before jumping into Spring Cloud, I am assuming you must be having knowledge of Eureka Server, Feign Client, and Client-Side load balancer. If not then read my below blog before jumping to Spring Cloud ribbon. Also, I am going to use my existing code to implement Ribbon . URLs: Declarative REST Client: Feign Microservices: Service Registry and Discovery Netflix Hystrix Circuit Breaker In my previous blog, I have already talked about the Eureka Server and how other applications are taking advantages of Eureka Server to fetch the host/port of client application. We have seen that three microservices application are up and running i.e. Discovery Server Product Service Price Service Where Product and Price service will register themselves to...

Declarative REST Client: Feign

Image
We already know that how microservices communicate with each other using RestTemplate. In this blog, we will see that how this can happen using Feign Client as well.  What is a Feign Client? Feign is an abstraction over REST based call. It makes writing web service clients easier. It Is as easy as creating interface and then annotate it. It has pluggable annotation support including Feign annotations and JAX-RS annotations. It also supports pluggable encoders and decoders and has supports for Spring MVC annotation. Using Feign, microservices can easily communicate with each other and developers don't have to bother about REST internal details and can only concentrate on business logic. Implementation. I am going to use my previous applications to demonstrate the working of Feign Client. So before starting feign-client application. Make sure all the below three applications are already up and running.  Discovery-server Product-server Price-server Feign Client Impl...

Microservices: Service Registry and Discovery

Image
In my previous blog, I have already talked about Netflix Hystrix Circuit Breaker Microservices and explained it by creating two applications i.e. Product Service and Price Service. In this post, I’ll use both applications to explain what is the Service Registry and Discovery Server. Circuit Breaker and Microservices Architecture Netflix Hystrix Circuit Breaker   What is Service Registry and Discovery and why do we need it in the first place? In our monolithic application, mostly service invoke one another through language methods or procedure calls and even in traditional distributed system deployment, services run at fixed, well-known locations (hosts and ports) and so can easily call one another using HTTP/REST. Over here the network locations of service instances are relatively static. With the microservice architecture system, this is a much more difficult problem as service instances have dynamically assigned network locations. Service instances change dynamicall...