spring-webclient

How to await when all http requests are finished using spring webClient?

拥有回忆 提交于 2019-12-24 19:14:01
问题 I want to execute http request for each queue element. These requests shoule be called in parallel. Also I need to await the termination of all requests. I developed the following code: List<Mono<MyResponseDTO>> monoList = queue.stream() .map(jobStatusBunch -> webClient .post() .uri("localhost:8080/api/some/url") .bodyValue(convertToRequestDto(someBean)) .retrieve() .toEntity(String.class) .filter(HttpEntity::hasBody) .map(stringResponseEntity -> { try { return objectMapper.readValue

How to intercept http response traffic in Spring WebClient / DataBuffer?

情到浓时终转凉″ 提交于 2019-12-13 03:15:14
问题 How can I intercept WebClient XML responses before they are converted from bytes to DTO? I tried adding an exchangeStrategy , but how could I convert DataBuffer to String, and afterwards still invoke the super.decode() method? ExchangeStrategies.builder().codecs((configurer) -> { configurer.defaultCodecs().jackson2JsonDecoder(new Jaxb2XmlDecoder() { @Override public Flux<Object> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Spring webflux WebClient logs 'Connection reset by peer'

冷暖自知 提交于 2019-12-08 07:51:16
问题 I have this following code which uses WebClient to make HTTP calls. webClient.post() .uri("/users/track") .body(BodyInserters.fromObject(getUserTrackPayload(selection, customAttribute, partyId).toString())) .header(CONTENT_TYPE, APPLICATION_JSON) .retrieve() .onStatus(httpStatus -> !CREATED.equals(httpStatus), response -> response.bodyToMono(String.class) .flatMap(body -> buildErrorMessage(response.statusCode().value(), body, partyId, customAttribute) .flatMap(e -> Mono.error(new MyException

Why webClient doesn't do any http call?

蹲街弑〆低调 提交于 2019-11-26 17:53:04
问题 I have following code: List<Mono<MyResponseDTO>> monoList = queue.stream() .map(jobStatusBunch -> webClient .post() .uri("localhost:8080/api/some/url") .bodyValue(convertToRequestDto(someBean)) .retrieve() .toEntity(String.class) .filter(HttpEntity::hasBody) .map(stringResponseEntity -> { try { return objectMapper.readValue(stringResponseEntity.getBody(), MyResponseDTO.class); } catch (JsonProcessingException e) { log.error("Can't parse", e); return null; } }) .doOnNext(myResponseDTO -> { log