Feign Client

Netflix provides Feign as an abstraction over REST-based calls, by which microservices can communicate with each other, but developers don’t have to bother about REST internal details. 1.Add the feign dependency to your project e.g. <dependency>           <groupId>org.springframework.cloud</groupId>           <artifactId>spring-cloud-starter-feign</artifactId> </dependency> 2.Tell to project that we will use Feign client, so scan its annotation, add the below annotation to your application class @EnableFeignClients 3. Now, we have to create an interface where we declare the services we want to call. Please note that Service Request mapping is same as the Actual Service Rest URL. @FeignClient(name=”MySearch” ) //Service Id of service you want to call public interface MySearchServiceProxy { – – – } 4. Add or create a Controller where we autowire our Feign Interface so Spring can Inject actual implementation during runtime. @RefreshScope @RestController public class FeignMySearchController {    @Autowired    MySearchServiceProxy… Read more“Feign Client”

Why Spring cloud is required?

When we develop microservices with Spring Boot , we might face the below mentioned issues hence spring cloud project helps to eliminate these issues.Spring cloud is set of tools to manage and establish the service Discovery, config management and Circuit Breakers etc. It manages and handles following very efficiently, 1. Any of the network and security issues. 2. Service discovery tools manage how processes and services in a cluster can find and talk to one another. It involves a directory of services, registering services in that directory, and then being able to lookup and connect to services in that directory. 3. Redundancy issues in distributed systems. 4. 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. 5. Performance issues due to various operational overheads. 6. Requirement of deployment and continuous integration.

JVM (Java) and it’s Memory Management

JVM (Java Virtual Machine) is an abstract machine or can say it is a software implementation of a Physical Machine. It is a specification that provides runtime environment in which java bytecode can be executed. JVMs are available for many hardware and software platforms (i.e. JVM is platform dependent). What is JVM It is: A specification: Where working of Java Virtual Machine is specified. But implementation provider is independent to choose the algorithm. Its implementation has been provided by Oracle and other companies. An implementation: Its implementation is known as JRE (Java Runtime Environment). Runtime Instance: Whenever you write java command on the command prompt to run the java class, an instance of JVM is created. What it does The JVM performs following operation: Loads code Verifies code Executes code Provides runtime environment JVM provides definitions for the: Memory area Class file format Register set Garbage-collected heap Fatal error reporting… Read more“JVM (Java) and it’s Memory Management”

Java OOPs

What are the principle concepts of OOPS? There are four principle concepts upon which object oriented design and programming rest. They are: Abstraction Polymorphism Inheritance Encapsulation (i.e. easily remembered as A-PIE). What is Abstraction? Abstraction refers to the act of representing essential features without including the background details or explanations. What is Encapsulation? Encapsulation is a technique used for hiding the properties and behaviors of an object and allowing outside access only as appropriate. It prevents other objects from directly altering or accessing the properties or methods of the encapsulated object. What is the difference between abstraction and encapsulation? Abstraction focuses on the outside view of an object (i.e. the interface) Encapsulation (information hiding) prevents clients from seeing it’s inside view, where the behavior of the abstraction is implemented. Abstraction solves the problem in the design side while Encapsulation is the Implementation. Encapsulation is the deliverables of Abstraction. Encapsulation barely… Read more“Java OOPs”

Installing java SDK and writing first java program

Installing and using Java Install the java SDK from below location and follow the installation instructions, http://www.oracle.com/technetwork/java/javase/downloads/index.html Setting environment variable for Java Environmental variable is a variable that describes the operating environment of the process. Common environment variables describe the home directory, command search path etc. JAVA_HOME JAVA_HOME is a environment variable (in Unix terminologies), or a PATH variable (in Windows terminology) which contains the path of Java installation directory. On window operating system follow the below steps, 1.Right click My Computer and select Properties. 2. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located. or run the below from command prompt, Set JAVA_HOME = <jdk-install-dir> example, C:\Program Files\Java\jdk1.6.0_02. On Unix operating system run the below command, export JAVA_HOME=<jdk-install-dir> CLASSPATH Set PATH =%PATH%;%JAVA_HOME%\lib\tools.jar PATH Set PATH =%PATH%;%JAVA_HOME%\bin; Please note, changing the JAVA_HOME will reflect to path and class path… Read more“Installing java SDK and writing first java program”

Core Java Architecture and JVM

In this lesson, we are going to explain the core Java Architecture. Java Java was conceived by a team of engineers in Sun Microsystems in 1991 as a part of a research project, which was led by James Gosling and Patrick Naughton. It was initially called Oak but was renamed as Java in 1995. This is designed to be small, simple, and portable across platforms and operating systems, both at the source and at the binary level, which means that the same Java program can run on any machine. Features of Java Java is an Object Oriented Language. Object-Oriented design is a technique that helps the programmer visualize the program using real-life objects. Java is a Simple Language. The reason is, Certain complex features like operator overloading, multiple inheritance, pointers, explicit memory de allocation are not present in Java language. Using Java we can write Robust Programs. The Two main… Read more“Core Java Architecture and JVM”

Object oriented concepts used in Java

Java is an Object-Oriented Language hence before learning java let us understand the object oriented Concepts first. Object An object in the software world means a bundle of related variables and functions known as methods variables and functions known as methods. Software objects are often used to model real-world objects you find in everyday life. The real world objects and software objects share two characteristics : 1. State : condition of an item. 2. Behaviour : Observable effects of an operation or event including its results. State can be of two types : Active state which reflects the behaviour and Passive State refers to state which does not change which does not change. The behaviour of an object forms the interface to the external world. Class A class is a blueprint or prototype that defines the variables and the methods (or funtions) common to all objects of a certain kind. Constituents… Read more“Object oriented concepts used in Java”

How to integrate elastic search with spring boot application

We can use elastic search with spring boot application and for this below are the detailed steps which can be followed. (Please note there some compatibility issue with some version of elastic search hence choose the appropriate one as per your need, I have used the version 2.4.0 with my spring boot app version 1.4.0.RELEASE) 1. Download and unzip the elastic search from http://www.elastic.co/downloads/past-releases/elasticsearch-2-4-0 2. Open config file \elasticsearch-2.4.0\config\elasticsearch.yml and change the cluster name if needed, uncomment and add the value to property 3. Run the elastic search by clicking on batch file, \elasticsearch-2.4.0\bin\elasticsearch.bat (Here this is going to run the elastic search on separate server than your application i.e localhost:9300 ) 4. Add the below dependency to your spring application

5. Add the below properties to application.properties file

6. To enable the elastic search repository which will be used to save/generate/delete the search indexes while application does… Read more“How to integrate elastic search with spring boot application”