Posts

Showing posts from June, 2024

Microservices Communication – Feign Client

Image
  Microservices Communication – Feign Client Spring cloud OpenFeign provides OpenFeign Integration for spring boot apps through auto configuration and binding to the spring environment Without feign client in spring boot application, we can use Rest Template to call user service. To use Feign client we need to add spring-cloud-starter-OpenFeign dependency in pom.xml In our project, if one micro-service accesses another microservice then is called inter-service communication ·          Rest Client (External Communication) ·          Web Client(External Communication) ·          Feign Client(Internal Communication) When we use feign client we do need to configure API URL to access. Using the API name we can access API (Feign client will get API URL from Service Registry) Feign Client is part of Spring Cloud Netflix Libraries Open Feign is decla...

Service Discovery - Eureka Server and Client

Image
  Steps to Build Service Discovery EUREKA SERVER Step 1 Create a Spring boot project and add dependency Step 2 Add the spring-cloud-starter-netflix-eureka-server dependency to your pom.xml file 1.        Web 2.        Actuator 3.        Eureka dependency Step 3 In your main application, annotate it with @EnableEurekaServer .this will enable Eureka Server Functionality Step 4 Configure Below properties in application. 1.        Application name 2.        Port number 3.        Enable Actuator 4.        Erueka Configuartion ·          Register with Eureka ·          Fetch Register ·          Default Zone URL Build and run the Eureka Server: Open a browser and ...

Rest API- Swagger Documentation

Image
Swagger Documentation Swagger is a set of tools built around the OpenAPI Specification that helps developers design, build, document, and consume RESTful web services. It allows developers to describe the structure of their APIs in a standardized format, making it easier for both humans and computers to understand and interact with the APIs. Step 1 Add Swagger Dependencies in pom.xml Step 2 Swagger URL : http://localhost:8090/swagger-ui/index.html To generate Swagger documentation, simply add the following dependencies to your pom.xml, start the Spring Boot application, and then access the specified URL in your browser.   To Customize Swagger Documentation In this document we applied swagger annotations in three levels 1.application level 2.controller level 3.Dto leve application level @OpenAPIDefinition : This annotation is used to provide metadata about your API. It's typically used in Spring applications to generate OpenAPI (formerly Swagger) documentation. ...