Spring boot/Spring WebClient — базовый HTTP-клиент завершился без отправки ответа.JAVA

Программисты JAVA общаются здесь
Anonymous
Spring boot/Spring WebClient — базовый HTTP-клиент завершился без отправки ответа.

Сообщение Anonymous »

Из микросервиса Spring Boot 3.3.3 — JDK 22 я пытаюсь связаться с микросервисом Spring Boot 3.1.6 — JDK 18, который, в свою очередь, выполняет асинхронные вызовы к третьему микросервису. Соединение между первым микросервисом и вторым работает правильно, но когда второй микросервис пытается асинхронно связаться с третьим, я получаю сообщение об ошибке: «Базовый HTTP-клиент завершил работу без отправки ответа».
Ниже приведен первый вызов (неасинхронный) второго микросервиса:
return mercurioDocumentApiClient.getWebClient().post()
.uri(UriComponentsBuilder.fromUriString(mercurioDocumentApiClient.getBasePath())
.path("/documents/upload")
.build()
.toUri()
)
.header("idSession", idSession)
.contentType(MediaType.MULTIPART_FORM_DATA)
.body(BodyInserters.fromMultipartData(multipartBodyBuilder.build()))
.retrieve()
.bodyToMono(Document.class)
.flatMap(document -> {
AllegaDocumentoDocumentaleOutputData allegaDocumentoDocumentaleOutputData = new AllegaDocumentoDocumentaleOutputData();
allegaDocumentoDocumentaleOutputData.setIdDocumento(BigDecimal.valueOf(Objects.requireNonNull(document.getId())));
allegaDocumentoDocumentaleOutputData.setRiferimentoDoc(null);
allegaDocumentoDocumentaleOutputData.setDocumentIdClient(document.getDocumentCode());
allegaDocumentoDocumentaleOutputData.setContentId(Long.valueOf(Objects.requireNonNull(document.getContentCode())));
return Mono.just(allegaDocumentoDocumentaleOutputData);
})
.block();

Другие вызовы, исходящие от второго микросервиса:
return filePartMono.flatMap(filePart -> {
// Check document id client
if (Objects.isNull(documentIdClientFormFieldPart) || StringUtils.isEmpty(documentIdClientFormFieldPart.value())) {
return webClient.flatMap(client -> {
DocumentCreateForm documentCreateForm = new DocumentCreateForm();
documentCreateForm.setTitle(filePart.filename());
documentCreateForm.path(String.valueOf(LocalDate.now().getYear()));

// Create new document
return client
.post()
.uri(uriBuilder -> uriBuilder.pathSegment("mercurio-contents", "api", "v1", "documents", mercurioProperties.getDomainCode(), mercurioProperties.getApplicationCode(), mercurioProperties.getContextCode(), "create").build())
.contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(documentCreateForm))
.retrieve()
.bodyToMono(DocumentResponse.class)
.flatMap(documentResponse -> {
if (Boolean.TRUE.equals(documentResponse.getSummary().getError())) {
return Mono.error(() -> new IllegalStateException(Arrays.toString(ListUtils.emptyIfNull(documentResponse.getSummary().getMessages()).toArray())));
}

log.info("Document created {}", Objects.requireNonNull(documentResponse.getPayload()).getDocumentIdClient());

return uploadFile(filePart.content(), filePart.filename(), pages, documentResponse.getPayload().getDocumentIdClient(), Optional.ofNullable(acquisitionStatusFormFieldPart).map(FormFieldPart::value).orElse(StringUtils.EMPTY), principal.getName());
});
});


Этот вызов вызывает ошибку
return client
.post()
.uri(uriBuilder -> uriBuilder.pathSegment("mercurio-contents", "api", "v1", "documents", mercurioProperties.getDomainCode(), mercurioProperties.getApplicationCode(), mercurioProperties.getContextCode(), "create").build())
.contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(documentCreateForm))
.retrieve()
.bodyToMono(DocumentResponse.class)
.flatMap(documentResponse -> {
if (Boolean.TRUE.equals(documentResponse.getSummary().getError())) {
return Mono.error(() -> new IllegalStateException(Arrays.toString(ListUtils.emptyIfNull(documentResponse.getSummary().getMessages()).toArray())));
}

log.info("Document created {}", Objects.requireNonNull(documentResponse.getPayload()).getDocumentIdClient());

return uploadFile(filePart.content(), filePart.filename(), pages, documentResponse.getPayload().getDocumentIdClient(), Optional.ofNullable(acquisitionStatusFormFieldPart).map(FormFieldPart::value).orElse(StringUtils.EMPTY), principal.getName());
});



Подробнее здесь: https://stackoverflow.com/questions/790 ... thout-emit

Вернуться в «JAVA»