9 Kasım 2020 Pazartesi

SpringCloud Netflix Zuul - API Gateway Kullanımı

Giriş
Açıklaması şöyle
- Zuul is the front door for all requests from devices and web sites to the backend of the Netflix streaming application.
- Zuul will serve as our API gateway
- Handle dynamic routing
- Zuul is built to enable dynamic routing, monitoring, resiliency and security.
Sürümler
Zuul 1 ve Zuul 2 sürümleri var. 
Zuul 1 "blocking api" kullanır.
Zuul 2 ise "non-blocking api" kullanır çünkü Zuul 2 altta netty kullanıyor. Açıklaması şöyle
Spring Cloud no longer supports Netflix Zuul.
Filter
Açıklaması şöyle
Zuul has mainly four types of filters that enable us to intercept the traffic in different timelines of the request processing for any particular transaction. We can add any number of filters for a particular URL pattern.
1. pre-filters — are invoked before the request is routed
2. post-filers — are invoked after the request has been routed
3. route-filters — are used to route the request
4. error-filters — are invoked when an error occurs while handling the request.
Şeklen şöyle
Kullanım
1. Her Zuul sunucusu aynı zamanda Eureka istemcisi olduğu için
@EnableDiscoveryClient veya @EnableEurekaClient anotasyonu eklenir
2. @EnableZuulProxy anotasyonu eklenir.
 
Maven
Şu satırı dahil ederiz
<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>,

Hiç yorum yok:

Yorum Gönder