Skip to content
Advertisement

Tag: spring-webflux

Reduce a flux to mono using data from flux

I have this scenario. I have one paginated API which gives me the data for last 12 months. The response of the API is like: Now I have to collect all the data and then calculate the sum of all the netReceivable and return as a Mono<CompanyIncome>. This pojo is like To do this I have written something like: Now

Spring Webflux – reactive repository saveAll(Iterable) vs saveAll(Publisher)

Small question about the webflux reactive repository, especially about the methods saveAll Flux saveAll(Iterable var1); versus Flux saveAll(Publisher var1); Wanted to compare, I wrote the following: In terms of “correctness” both codes are doing what is expected. Everything is persisted successfully. But in terms of performance, reactive paradigm, IO Utilisations to DB, Netty Core usage, what is the “best” solution

Spring Webflux – Proper way to throw checked custom exception (not RuntimeException)

May I ask what is the proper way to throw checked custom exception in Spring webflux please? I would like to insist, it is about checked custom exception, like MyException.java, not something like RuntimeException, and it is about throwing exception, not handling exception. I tried the following : This is not possible, since there in an unhandled exception in getSecondStepFromFirstStepAfterCheck

WebClient – adding defaultHeaders

I’m trying to put multiple headers into defaultHeaders(), But I don’t have idea how to create Consumer object from return of createHeaders() method I can build my header in that way: but how to wrap it into Consumer? Answer Clearly the method doc says that it needs a Consumer of some Type. So you can create an anonymous class implementing

Which design pattern for merging 2 methods they differ in one place

I wonder which design pattern should I use in my case: I have 2 endpoints that use 2 service methods, each very similar, they differ only in invoking some different methods from the same service: My first service method (invoked by endpoint 1): The second endpoint uses very similar method that differs in protectionCommandService.sendUnprotected (deleteBBB). My secondservice method (invoked by

WebTestClient – CORS with Spring Boot and Webflux

I have Vuejs frontend and a Spring Boot Webflux controller. Now the browser is complaining with CORS when doing a call to Spring Boot. Access to XMLHttpRequest at ‘https://…’ from origin ‘https://…’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. To enable CORS I

Advertisement