Powered by Blogger.

Thursday 2 June 2022

Run Multiple Microservices on single Port Using Zuul

1 comment :
Information
As you must have seen in these blogs links Multiple Microservices with Eureka Client Configuration that how we develop microservices and register those services on eureka server and we have seen how every service run on different port Number.
Introduction
Zuul is a JVM- based router and server-side load balance form Netflix.
Zuul's rule engine provides flexibility to write rules and filters to enhance routing in a spring cloud microservices architecture.
Routing it is an integral port of a microservice architecture.
How to Include Zuul Dependency
dependency: 
                groupid: org.springframework.cloud 
                 artifactid: spring-cloud-starter-netflix-zuul

Enbedded Zuul Reverse Proxy To enable it, annotate a spring boot man class with @EnableZuulProxy.
How to write Main Class Name is:A143mkGatewayApplication.java

Filter Class
Base abstract class for Zuulfilters. the base class defines abstract methods to define: filterType()- to classify a filter by type. standard type in Zuul are
  1. ErrorFilter
  2. PostFilter
  3. PreFilter
  4. RouteFilter

ErrorFilter.java

PostFilter.java

PreFilter.java

RouteFilter.java

application.properties
## client1-1 API URL 
zuul.routes.client-service-1.path=/cli-api/** 
zuul.routes.client-service-1.url=http://localhost:8081/ 
## client1-2 API URL 
zuul.routes.client-service-2.path=/cli2-api/** 
zuul.routes.client-service-2.url=http://localhost:8082/ 
ribbon.eureka.enabled=false 
server.port=8080

Create pom.xml

For step by step development working watch the video and learn yourself.





1 comment :

  1. Good example of multiple Microservices run in single getaway

    ReplyDelete

Please Write a Message for Programming or something Related issues.