Continuing on, Zuul is a router and a server-side load balancer developed and popularized by Netflix. Zuul uses ribbon to call the remote se...
@EnableZuulProxy also enables 2 additional endpoints:
- Routes - a get to this endpoint returns a list of map routes, to get more details, add the query param format=details
- Filters - a get to this endpoint returns a map of Zuul filters
- Create a new SpringBoot and add the following dependencies
- spring-cloud-starter-netflix-zuul
- spring-cloud-starter-netflix-eureka-client - register this server to the service discovery
- spring-boot-starter-web and spring-boot-starter-actuator to expose server information
- Annotate the SpringBoot class with @EnableZuulProxy and @EnableDiscoveryClient.
- Configuration the application name, port, eureka instance and Zuul in the property file.
Run the projects in the following order
- Terawarehouse-config-server
- Terawarehouse-service-discovery
- Terawarehouse-load-balancer
- Terawarehouse-catalog
- <network_ip>:8000/catalog/default</network_ip>
- <network_ip>:8761</network_ip>
- <network_ip>:8001/api/v1/categories</network_ip>
- <network_ip>:8762/routes</network_ip>
- <network_ip>:8762/filters</network_ip>
- <network_ip>:8762/catalog/api/v1/categories</network_ip>
And that concludes this video. I hope this information will be of use to you when you decided to develop your own project using the microservice architecture.
I would appreciate if you could subscribe to my channel to get notified when I upload the next video and that will validate that what I’m doing is helpful for others, which will definitely inspire me to share more technical videos.
References
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
application: | |
name: load-balancer | |
server: | |
port: 8762 | |
eureka: | |
instance: | |
prefer-ip-address: true | |
client: | |
register-with-eureka: true | |
fetch-registry: true | |
service-url: | |
defaultZone: http://192.168.1.100:8761/eureka | |
management: | |
endpoints: | |
web: | |
exposure: | |
include: | |
- '*' | |
base-path: / | |
zuul: | |
sensitive-headers: # default value is Cookie, Set-Cookie, Authorization | |
add-proxy-headers: false | |
retryable: true | |
#prefix: /api | |
routes: | |
catalog: | |
path: /catalog/** | |
service-id: catalog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SpringBootApplication | |
@EnableZuulProxy | |
@EnableDiscoveryClient | |
public class TerawarehouseLoadBalancerApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(TerawarehouseLoadBalancerApplication.class, args); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-web</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-actuator</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.cloud</groupId> | |
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.cloud</groupId> | |
<artifactId>spring-cloud-starter-netflix-zuul</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-devtools</artifactId> | |
<scope>runtime</scope> | |
<optional>true</optional> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-test</artifactId> | |
<scope>test</scope> | |
<exclusions> | |
<exclusion> | |
<groupId>org.junit.vintage</groupId> | |
<artifactId>junit-vintage-engine</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency> | |
</dependencies> |
COMMENTS