add request response
This commit is contained in:
@@ -118,6 +118,22 @@ stages:
|
|||||||
image: $(containerRegistry)/$(imageRepository):$(tag)
|
image: $(containerRegistry)/$(imageRepository):$(tag)
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /actuator/health
|
||||||
|
port: 8080
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
timeoutSeconds: 2
|
||||||
|
periodSeconds: 5
|
||||||
|
failureThreshold: 10
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /products/1
|
||||||
|
port: 8080
|
||||||
|
initialDelaySeconds: 120
|
||||||
|
timeoutSeconds: 2
|
||||||
|
periodSeconds: 5
|
||||||
|
failureThreshold: 5
|
||||||
secretType: 'dockerRegistry'
|
secretType: 'dockerRegistry'
|
||||||
containerRegistryType: 'Azure Container Registry'
|
containerRegistryType: 'Azure Container Registry'
|
||||||
- task: Kubernetes@1
|
- task: Kubernetes@1
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ steps:
|
|||||||
initialDelaySeconds: 10
|
initialDelaySeconds: 10
|
||||||
timeoutSeconds: 2
|
timeoutSeconds: 2
|
||||||
periodSeconds: 5
|
periodSeconds: 5
|
||||||
failureThreshold: 5
|
failureThreshold: 10
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /products/1
|
path: /products/1
|
||||||
|
|||||||
6
pom.xml
6
pom.xml
@@ -79,6 +79,12 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- hystrix circuit breaker -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Add Stackdriver Trace Starter -->
|
<!-- Add Stackdriver Trace Starter -->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>org.springframework.cloud</groupId>-->
|
<!-- <groupId>org.springframework.cloud</groupId>-->
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ package com.example.template;
|
|||||||
import com.example.template.config.kafka.KafkaProcessor;
|
import com.example.template.config.kafka.KafkaProcessor;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableBinding(KafkaProcessor.class)
|
@EnableBinding(KafkaProcessor.class)
|
||||||
|
@EnableCircuitBreaker
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
protected static ApplicationContext applicationContext;
|
protected static ApplicationContext applicationContext;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.example.template;
|
package com.example.template;
|
||||||
|
|
||||||
|
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -47,6 +48,7 @@ public class ProductController {
|
|||||||
|
|
||||||
|
|
||||||
@PatchMapping("/product/{productId}")
|
@PatchMapping("/product/{productId}")
|
||||||
|
@HystrixCommand(fallbackMethod = "certifyFallBack")
|
||||||
ResponseEntity<String> fakeProductPatch(@PathVariable(value = "productId") Long productId, @RequestBody String data) {
|
ResponseEntity<String> fakeProductPatch(@PathVariable(value = "productId") Long productId, @RequestBody String data) {
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
@@ -60,4 +62,12 @@ public class ProductController {
|
|||||||
|
|
||||||
return ResponseEntity.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count));
|
return ResponseEntity.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResponseEntity<String> certifyFallBack(Long productId, String data){
|
||||||
|
|
||||||
|
System.out.println("certifyFallBack");
|
||||||
|
System.out.println(data);
|
||||||
|
|
||||||
|
return ResponseEntity.ok("시스템이 혼잡합니다!! 잠시후 다시 호출해주세요");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user