All posts by Ankur Mhatre

Spring Cloud: Creating REST Client Using Ribbon

This is a quick tutorial for creating a REST API client using Spring Cloud Ribbon component. For this tutorial you will need a running Eureka server and a Eureka client application. In case if you do not have Eureka server or a Eureka client application, check out my previous posts which explains how to setup eureka server and how to develop a eureka client application.

What is Ribbon?

In short, Ribbon is a load balancer. Let’s say you have a service which is used by 1000’s of customers. In that case you may have multiple instances of service running on multiple servers for load balancing purpose. Now if you want to consume that service in another service, you should not hard code its URL. Because that will always point to only one service and will defeat the purpose of load balancing.

Ribbon helps us to solve this issue. Ribbon on backend talks with Eureka server and will get all instances of services and try to distribute the load across instances.

TL;DR You can download whole project by clicking following link.

To give you a brief idea about the project… We will have a producer which we will be launching multiple times. We will be creating a consumer with Ribbon which will consume the service exposed by producer. At same time it will take care of load balancing as well.

Continue reading Spring Cloud: Creating REST Client Using Ribbon

Spring Cloud: Creating Student Service With Eureka

In this post we will be creating an eureka client application. We will be creating a sample Student service. This service will have two functionalities viz. to retrieve information about all students or you can pass a specific student id and retrieve information of that particular student.

We will be also making some changes in application.properties file to spin multiple instances of this application on same/one machine.

TL;DR You can download whole project by clicking following link.

Before we begin, you will need to setup eureka server. In case if you don’t know how to setup eureka server then please checkout Setting Up Eureka Server Using Spring Cloud first.

Continue reading Spring Cloud: Creating Student Service With Eureka

Spring Cloud: Consuming Eureka client application With another eureka client and Rest Template (Part 3)

This is a quick tutorial for consuming services exposed by one Eureka client application in another Eureka client application. This tutorial has prerequisite of a running Eureka server and a Eureka client application as well. In case if you do not have Eureka server or a Eureka client application, check out my previous posts in this series which explains how to setup eureka server and how to develop a eureka client application. The eureka client which we will be developing in this tutorial will be registered in eureka server and will consume service exposed by another client application.

TL;DR You can download whole project by clicking following link.

To give you a brief idea about what we are developing.. We will be creating a Eureka client in this tutorial. The client will be a spring boot application and will expose one rest endpoint. The client will also internally consume service exposed by another eureka client application.

Continue reading Spring Cloud: Consuming Eureka client application With another eureka client and Rest Template (Part 3)

Spring Cloud: Creating first client application With eureka client (Part 2)

This is a quick tutorial for creating eureka client application. This tutorial has prerequisite of a running eureka server. In case if you do not have running eureka server or a newbie, check out my previous post in this series which explains how to setup eureka server yourself. The eureka client which we will be developing in this tutorial will be registered in eureka server.

TL;DR You can download whole project by clicking following link.

We will be creating a Eureka client in this tutorial. The client will be a spring boot application and will expose one rest endpoint. That endpoint will accept one value (or String, as said in Java world) as path parameter and will prefix it with ‘Hello’. The endpoint will return its result as String again.

Continue reading Spring Cloud: Creating first client application With eureka client (Part 2)

Setting Up Eureka Server Using Spring Cloud (Part 1)

This is a quick example for setting up Eureka server using Spring Cloud.

You can download the whole project by using following link.

For this tutorial we will be creating a New Maven Project. To keep thing more simple we will be creating a simple maven project i.e. we will be skipping archetype selection.

New Maven Project Wizard – Creating a simple project
Continue reading Setting Up Eureka Server Using Spring Cloud (Part 1)

Struts 2 Hello World Example (XML Version)

In this tutorial, we will be creating a simple “Hello world” program using Struts 2. For this tutorial we will be using Eclipse, Struts 2. Struts 2 allows you to define configuration either by using traditional Struts 1 like XML way or by using annotations. In this tutorial we will be following traditional XML way. Let’s move ahead!
Continue reading Struts 2 Hello World Example (XML Version)