0

I'm using OpenFeign in order to communicate syncrounsly between two microservices Order and Inventory.

Microservice Order has one method configured with 3 annotations from resilience4j as follows:

    @PostMapping
    @TimeLimiter(name="inventory")
    @CircuitBreaker(name="inventory")
    @Retry(name = "inventory")
    public CompletableFuture<String> placeOrder(@RequestBody OrderRequest orderRequest) {
        return CompletableFuture.supplyAsync(()->orderService.placeOrder(orderRequest));
    }

How to configure fallback in order to response different status code depending from the exception:

  • If Inventory is not available (down) I would like to response a HttpStatus.NOT_FOUND
  • If Inventory is lagging I would like to response a HttpStatus.REQUEST_TIMEOUT
gustavomr
  • 69
  • 2
  • 16

0 Answers0