spring-webflux

Webclient maven Dependency errors

人盡茶涼 提交于 2021-01-28 19:04:22
问题 I am getting a NoClassDefFoundError on the line where I try to create WebClient instance using ' create '. Tried builder() but still the same thing. Please tell me what's wrong with the dependencies which I have added and how this issue can be solved. webClient = WebClient.create(url) .post() .uri(uri) .contentType(MediaType.APPLICATION_JSON) .body(BodyInserters.fromMultipartData(map)) .retrieve() .bodyToMono(Object.class) .block() .toString() dependencies which I added are <dependency>

Connection-reuse and transactions (relationship)

↘锁芯ラ 提交于 2021-01-28 05:00:24
问题 How does R2DBC implement transaction-handling. As far as I know, JDBC use one connection for one transaction. So in Spring MVC we have the following mapping: 1 request : 1 thread : 1 transaction : 1 connection. What is the mapping in Webflux with R2DBC? Webflux is reactive, so when we open one transaction, does it use one connection until the end of the transaction? If so, then a transaction is something like a blocking operation because, while the transaction is active no other transaction

How can I create reactor Flux from a blocking queue?

百般思念 提交于 2021-01-28 00:30:22
问题 I am trying to implement a reactor Flux created from a BlockingQueue but not sure which operator is best for my use case? I am creating a streaming REST end point, where response is Flux that needs to keep emitting messages from a BlockingQueue as a response to GET REST call. I have already tried forums and documentation and can only find Flux initiated from iterable collections or reactive data sources, but no examples from any BlockingQueue. 回答1: You can try Flux#generate and Queue#peek.

Issue with Spring Webflux webclient , nothing happens when trying to send post request

拜拜、爱过 提交于 2021-01-27 07:00:37
问题 Have the following implementation of webclient : public <T> WebClient.ResponseSpec sendRequest(HttpMethod method, String contentType, T body, String baseUrl, String path) { try { WebClient webClient = WebClient.builder().baseUrl(baseUrl).filter(logRequest()).build(); WebClient.ResponseSpec responseSpec = webClient.method(method) .uri(path) .header(HttpHeaders.CONTENT_TYPE, contentType) .body(BodyInserters.fromObject(body)) .retrieve(); return responseSpec; } catch (Exception e) { throw new

Issue with Spring Webflux webclient , nothing happens when trying to send post request

大憨熊 提交于 2021-01-27 06:55:52
问题 Have the following implementation of webclient : public <T> WebClient.ResponseSpec sendRequest(HttpMethod method, String contentType, T body, String baseUrl, String path) { try { WebClient webClient = WebClient.builder().baseUrl(baseUrl).filter(logRequest()).build(); WebClient.ResponseSpec responseSpec = webClient.method(method) .uri(path) .header(HttpHeaders.CONTENT_TYPE, contentType) .body(BodyInserters.fromObject(body)) .retrieve(); return responseSpec; } catch (Exception e) { throw new

Error when using @EnableWebFluxSecurity in springboot

我与影子孤独终老i 提交于 2021-01-22 07:54:03
问题 Currently I´m trying to integrate JWT Authentication in an existing Spring Boot Webflux Project. As a template I used this medium article: https://medium.com/@ard333/authentication-and-authorization-using-jwt-on-spring-webflux-29b81f813e78. If I put the Annotation @EnableWebFluxSecurity inside my WebSecurityConfig the following error occurs: The bean 'conversionServicePostProcessor', defined in class path resource [org/springframework/security/config/annotation/web/configuration

Error when using @EnableWebFluxSecurity in springboot

血红的双手。 提交于 2021-01-22 07:52:47
问题 Currently I´m trying to integrate JWT Authentication in an existing Spring Boot Webflux Project. As a template I used this medium article: https://medium.com/@ard333/authentication-and-authorization-using-jwt-on-spring-webflux-29b81f813e78. If I put the Annotation @EnableWebFluxSecurity inside my WebSecurityConfig the following error occurs: The bean 'conversionServicePostProcessor', defined in class path resource [org/springframework/security/config/annotation/web/configuration

Webflux Kotlin Coroutines Flow doesn't return any results

倖福魔咒の 提交于 2021-01-07 06:41:13
问题 My Spring repository implement a function to return a kotlinx.coroutines.flow.Flow of User but it seems this flow is always empty even if there are some record in my DB. I am using Spring Boot 2.2.0-SNAPSHOT with the Kotlin coroutines support. I created two methods in my repository, one to create an user and one to list all users. The one to create an user works and I can see this user in my DB. The second one to list existing users returns an empty list, always, even if my DB has some

Webclient : java.lang.OutOfMemoryError: Direct buffer memory

泄露秘密 提交于 2021-01-05 11:25:50
问题 I am getting java.lang.OutOfMemoryError: Direct buffer memory error at the web client. The batch job runs daily. It fails twice then passed in the third attempt. at org.springframework.retry.support.RetryTemplate.rethrow(RetryTemplate.java:532) ~[spring-retry-1.2.5.RELEASE.jar:na] Caused by: java.lang.OutOfMemoryError: Direct buffer memory at reactor.netty.http.client.HttpClientDoOnError$OnErrorTcpClient.connect(HttpClientDoOnError.java:242) ~[reactor-netty-0.9.11.RELEASE.jar:0.9.11.RELEASE]

How to combine ResponseEntity with Flux or Mono For CRUD operations

眉间皱痕 提交于 2021-01-05 08:50:25
问题 Hi i am trying to create a CRUD controller with repository but i couldn't find any example for using as reference. I want to do something like this below. @RequestMapping(value = "/api/open/books", method = RequestMethod.GET) public ResponseEntity<Flux<Book>> getBooks() { Flux<Book> books = bookRepository.findAll(); // if books is null return new ResponseEntity<Flux<Book>>(books, HttpStatus.NOT_FOUND); // else return new ResponseEntity<Flux<Book>>(books, HttpStatus.OK); } @RequestMapping