Posts

Showing posts from July, 2017

Working with Ribbon with out Eureka

Pom.xml: ======= (?xml version="1.0" encoding="UTF-8"?) (project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd") (modelVersion)4.0.0(/modelVersion) (groupId)com.example(/groupId) (artifactId)RibbonWithoutEureka(/artifactId) (version)0.0.1-SNAPSHOT(/version) (packaging)jar(/packaging) (name)RibbonWithoutEureka(/name) (description)Demo project for Spring Boot(/description) (parent) (groupId)org.springframework.boot(/groupId) (artifactId)spring-boot-starter-parent(/artifactId) (version)1.5.6.RELEASE(/version) (relativePath/) (!-- lookup parent from repository --) (/parent) (properties) (project.build.sourceEncoding)UTF-8(/project.build.sourceEncoding) (project.reporting.outputEncoding)UTF-8(/project.reporting.outputEncoding) (java.version)1.8(/java.version) (/propertie...

Spring Cloud- REST call using Netflix Feign Client

Image
In this post we implement the Netflix Feign client. Previously we had implemented Load Balancing using Netflix Ribbon. The netflix ribbon code here will be the starting point. Will only be making changes in the employee-consumer module by adding the Netflix Feign code. The employee-producer and Eureka Server code will remain the same. What is the Netflix Feign Client? Need for it? Feign is a java to http client binder inspired by Retrofit, JAXRS-2.0, and WebSocket. Feign's first goal was reducing the complexity of binding Denominator uniformly to http apis regardless of restfulness. Previous examples in the employee-consumer we consumed the REST services exposed by the employee-producer using REST Template But we had to write a lot of code to perform following- For Load balancing using Ribbon. Getting the Service instance and then the Base URL. Make use of the REST Template for consuming service. The previous code was as below @Controller public class ConsumerControllerClient { ...

Circuit Breaker using Hystrix

Image
What is the Netflix Hystrix Circuit Breaker Feature? Need for it? In previous posts we had two services- employee-consumer consuming the service exposed by the employee-producer. Due to some reason the employee-producer exposed service throws an exception. In this case using Hystrix we defined a fallback method. In case of exception in the exposed service the fallback method returned some default value. If the exceptions keep on occuring in the firstPage method() then the Hystrix circuit will break and the employee consumer will skip the firtsPage method all together and directly call the fallback method. The purpose of circuit breaker is to give time to the first page method or other methods that the firstpage method might be calling and is causing the exception to recover. It might happen that on less load the issue causing the exceptions have better chance of recovering The employee-producer had the following firstpage method annotated with the hystrix annotation. Producer Code: pac...

Eureka- Ribbon - Histrix - Producer -Consumer

Image
What is Load Balancing? Need for Netflix Ribbon In computing, load balancing improves the distribution of workloads across multiple computing resources, such as computers, a computer cluster, network links, central processing units, or disk drives. Load balancing aims to optimize resource use, maximize throughput, minimize response time, and avoid overload of any single resource. Using multiple components with load balancing instead of a single component may increase reliability and availability through redundancy. Load balancing usually involves dedicated software or hardware, such as a multilayer switch or a Domain Name System server process. In previous posts we developed two services employee-producer and employee-consumer. Suppose other modules are also calling and consuming employee-producer module services. So the load at employee-producer is high. To deal with this we this we deploy multiple instances of employee-producer. Suppose two in this case. Now we will have to use a Loa...

Eureka Registry - Ribbon Load balancer - Application Producer - Application Consumer

Eureka : Expose Service API, it have own Server Ribbon : load balancer at client side Histrix : circut breaking, exception hander at application server side bootstrap.yml: eureka:   client:     registerWithEureka: false     fetchRegistry: false   server:       waitTimeInMsWhenSyncEmpty: 0   instance:     hostname: localhost Eureka Server : Pom.xml (?xml version="1.0" encoding="UTF-8"?) (project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd") (modelVersion)4.0.0(/modelVersion) (groupId)com.example(/groupId) (artifactId)EurekaServer(/artifactId) (version)0.0.1-SNAPSHOT(/version) (packaging)jar(/packaging) (name)EurekaServer(/name) (description)Demo project for Spring Boot(/description) (parent) (groupId)org.springframework.boot(/groupId) (artifactId)spring-boot-starter-pa...

spring-cloud-dependencies

1.Dalston.SR1 2.Camden.RELEASE 3.Brixton So for example if you are using Spring Boot 1.2 then go with Angel, 1.3 then Brixton, 1.4+ then Camden is probably your best bet. Even then you can always get things working by resolving dependency conflicts yourself. Microservice Registration with Spring cloud using Netflix Eureka When we start a project, we usally have all the configurations in the properties file. As more and more services are developed and deployed, adding and modifying these properties become more complex. Some services might go down, while some the location might change. This manual changing of properties may create issues. Eureka Service Registration and Discovery helps in such scenarios. As all services are registered to the Eureka server and lookup done by calling the Eureka Server, any change in service locations need not be handled and is taken care of This Post is divided into 4 parts- a.) Overview of Netflix components. b.) Develop an Employee service to produce and...