I am trying to create a POST API using JAVA web-flux. In this API I want to create a list of string and make a database call to get Mono<List> as a response but when I am trying to convert Mono<List> to simple list object using block() I'm getting below response:
{
"code": 500,
"message": "block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-8"
}
How can I convert Mono object to simple List object?
I'm using below code:
List<String> paymentInstrumentIdList = paymentInstrumentRequest.getPaymentInstruments().stream().map(PaymentInstrumentData::getPaymentInstrumentId).collect(Collectors.toList());
Mono<List<PaymentInstrument>> paymentInstrumentList = paymentInstrumentRepository.getByPartitionKey(partitionKey.toString(), DocType.PAYMENT_INSTRUMENT, paymentInstrumentIdList);
return ResponseEntity.ok(responseMapper.getResponseAsClass(graphQlQueryController.queryPaymentInstrumentsByPaymentInstrumentId(baseHeaders, personId, membershipId, paymentInstrumentList.block()), Wallet.class, "Wallet"));