1

私たちのプロジェクトでは、マイクロ サービス間の通信に WebClient Builder 呼び出しを使用しています。これは springboot-thymleaf-webflux ベースのアプリケーションです。これまではすべて正常に動作していましたが、クライアントから、thymleaf コントローラーで GET 呼び出しを POST 呼び出しに変更するよう要求されました。 UI とバックエンドでこれらの変更を行った後、Thymleaf 呼び出しは正常に動作していますが、XHR の 1 つ、つまり UI からの post 呼び出しで、最初のクリックで 2 番目のマイクロサービスへの Webclient 呼び出しに対して不適切な要求エラーが発生し、2 番目のクリックで機能しています。両方のクリックのリクエストで違いが見つかりませんでした.webclientが最初は異常に動作し、2回目は正常に動作する理由を理解できません。以下は、webclient 呼び出しのコード スニペットであり、BAD Request for と言って 2 番目のマイクロサービスにヒットすることなく、WebclientResponseException にルーティングされます。http://second- microservice -eureka-address/endpoint-url

     * Submitting xyz 
     * @param submitFlowRequest
     */
    @Override
    public Mono<ApiResponse<SubmitResponse>> submitFlow(SubmitFlowRequest submitFlowRequest,
            Map<String, String> headers) {
        long startTime = System.currentTimeMillis();
        String uri = propertyConfig.getAggregationService()
                + propertyConfig.getAggregationSubmitCCInfoURL();
        DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(uri);
        factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.URI_COMPONENT);
        MultiValueMap<String, String> clientHeaders = buildHeaders(headers);
        return webClientBuilder.uriBuilderFactory(factory).build().post()
                .headers(httpHeaders -> httpHeaders.addAll(clientHeaders)).accept(MediaType.APPLICATION_JSON)
                .syncBody(submitFlowRequest).retrieve().bodyToMono(ApiResponse.class)
                .onErrorMap(ConnectException.class,
                        error -> new VzwRuntimeException(ErrorCodeEnum.V404.toString(), Constants.OPP_TC_SYSTEM_ERROR,
                                (Constants.CONNECTION_FAILURE_TEXT + Constants.AGGREGATION)))
                .onErrorMap(WebClientResponseException.class,
                        error -> new VzwRuntimeException(ErrorCodeEnum.V404.toString(), Constants.OPP_TC_SYSTEM_ERROR,
                                (Constants.CONNECTION_FAILURE_TEXT + Constants.AGGREGATION)))
                .flatMap(res -> {
                    Audit apiAudit = Audit.builder().apiUrl(uri).request(LoggerUtil.asJson(submitFlowRequest))
                            .response(LoggerUtil.asJson(res))
                            .executionTime(String.valueOf(System.currentTimeMillis() - startTime))
                            .headers(LoggerUtil.asJson(clientHeaders)).transactionType(res.getData()!=null?mapper.map(res.getData(), SubmitResponse.class).getTransactionType():"").build();
                    LoggerUtil.logExternalApiCalls(apiAudit);
                    return Mono.just((ApiResponse<SubmitResponse>) res);
                });
    }```

Please provide me some lead.I am tired of finding solution for this.
4

1 に答える 1