添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

我在java spring boot中的微服务正试图通过Feign访问另一个微服务,但我得到一个 503 Service Unavailable Error 。问题是,我不知道为什么会发生这个错误,除了这个消息,调试也没有说什么。我研究并尝试了其他建议来寻找错误的原因,但没有成功。有没有一个确切的方法来显示错误的原因?如果不清楚的话,我可以更好地解释。这是我的情况。

我试图访问的端点的Swagger。 POST -> /customers/cards/profiles/{profileId}/search

application.properties:

customer.endpoint=${url.apis.aws.v1}/customers
customer.token-uri=${customer.endpoint}/oauth2/token
customer.token-grant-type=client_credentials
customer.token-client-id=${client-id}
customer.token-client-secret=${client-secret}
customer.token-scope=read

Client:

@FeignClient(url = "${customer.endpoint}", name = "customer", configuration = CustomerOAuth2FeignConfig.class)
public interface CustomerClient {
    @PostMapping("/cards/profiles/{profileId}/search")
    public PageResponse<CustomerResponse> getCustomer(@PathVariable("profileId") Long profileId,
            @SpringQueryMap CustomerRequest customerRequest);

request:

@Retryable(value = { Unauthorized.class, FeignException.class }, maxAttempts = 3, backoff = @Backoff(delay = 50))
    public HttpResponse<List<CustomerResponse>> getCustomer(Long profileId, CustomerRequest customerRequest) {
        var response = new HttpResponse<List<CustomerResponse>>();
        var customers = new ArrayList<CustomerResponse>();
        try {
            var customerResponse = customerClient.getCustomer(profileId, customerRequest);
            customers.addAll(customerResponse.getContent());
            response.setContent(customers);
        } catch (Unauthorized ex) {
            log.warn(LOG_TOKEN_EXPIRED, CUSTOMER_SERVICE, METHOD_GET_CUSTOMER);
            throw ex;
        } catch (NotFound e) {
            response.setThrowable(e);
        } catch (FeignException feignEx) {
            throw feignEx;
        return response;

StackOverflow:https://stackoverflow.com/questions/68198719/diagnosing-a-503-service-unavailable-feign-exception-in-microservice-java-spring