spring-webflux

If I use a reactive client, should the server be reactive too?

China☆狼群 提交于 2021-01-01 08:50:22
问题 I want to use a reactive client (Reactive WebSocketClient i.e ReactorNettyWebSocketClient) to talk to a server which I don't know if it is reactive or not. Does it make sense to use a reactive client to talk to a server which is not reactive? I tried to connect to a server probably not reactive, and I got this error: io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 999 Unknown at io.netty.handler.codec.http.websocketx

If I use a reactive client, should the server be reactive too?

馋奶兔 提交于 2021-01-01 08:50:15
问题 I want to use a reactive client (Reactive WebSocketClient i.e ReactorNettyWebSocketClient) to talk to a server which I don't know if it is reactive or not. Does it make sense to use a reactive client to talk to a server which is not reactive? I tried to connect to a server probably not reactive, and I got this error: io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 999 Unknown at io.netty.handler.codec.http.websocketx

Springboot : How to use WebClient instead of RestTemplate for Performing Non blocking and Asynchronous calls

强颜欢笑 提交于 2020-12-29 06:12:15
问题 I have a springboot project which uses Springboot Resttemplate. We have moved to springboot 2.0.1 from 1.5.3 and we are trying to make the rest calls from it asynchronous by using WebClient. We used to process the string received using Resttemplate as given below. But WebClient returns only data in Mono or Flux. How can I get the data as String. Already tried block() method , but it does asynchronous calls. @Retryable(maxAttempts = 4, value = java.net.ConnectException.class, backoff =

Springboot : How to use WebClient instead of RestTemplate for Performing Non blocking and Asynchronous calls

一笑奈何 提交于 2020-12-29 06:08:56
问题 I have a springboot project which uses Springboot Resttemplate. We have moved to springboot 2.0.1 from 1.5.3 and we are trying to make the rest calls from it asynchronous by using WebClient. We used to process the string received using Resttemplate as given below. But WebClient returns only data in Mono or Flux. How can I get the data as String. Already tried block() method , but it does asynchronous calls. @Retryable(maxAttempts = 4, value = java.net.ConnectException.class, backoff =

Springboot : How to use WebClient instead of RestTemplate for Performing Non blocking and Asynchronous calls

跟風遠走 提交于 2020-12-29 06:08:32
问题 I have a springboot project which uses Springboot Resttemplate. We have moved to springboot 2.0.1 from 1.5.3 and we are trying to make the rest calls from it asynchronous by using WebClient. We used to process the string received using Resttemplate as given below. But WebClient returns only data in Mono or Flux. How can I get the data as String. Already tried block() method , but it does asynchronous calls. @Retryable(maxAttempts = 4, value = java.net.ConnectException.class, backoff =

Mono.Defer() vs Mono.create() vs Mono.just()?

限于喜欢 提交于 2020-12-29 03:54:43
问题 Could someone help me to understand the difference between Mono.defer(), Mono.create() and Mono.just()? How to use it properly? 回答1: Mono.just(value) is the most primitive - once you have a value you can wrap it into a Mono and subscribers down the line will get it. Mono.defer(monoSupplier) lets you provide the whole expression that supplies the resulting Mono instance. The evaluation of this expression is deferred until somebody subscribes. Inside of this expression you can additionally use

How to implement authorization header checking using WebFilter

浪尽此生 提交于 2020-12-15 19:08:53
问题 I am new to Spring Webflux. I want to use WebFilter to do authentication checking. So, the idea is intercepting the request, checking the Authorization header, and propagate the request Here is what I have tried to do. I have successfully intercept the request and check whether the header is correct or not. public class AuthWebFilter implements WebFilter { @Override public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) { log.info("Request {} called", exchange.getRequest()

Spring boot with WebFlux always throw 403 status in tests

不问归期 提交于 2020-12-05 11:54:10
问题 Great thx for viewing my question) I have some strange subject: my spring boot tests don't work. They start successfully but always throwing 403 HTTP status when making the requests to any controller I have some project with next dependencies: buildscript { ext.kotlin_version = '1.3.71' dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.71" classpath "org.springframework.boot:spring-boot-gradle-plugin:2.2.1.RELEASE" classpath "com.google.cloud.tools.jib:com.google.cloud

Spring boot with WebFlux always throw 403 status in tests

妖精的绣舞 提交于 2020-12-05 11:48:25
问题 Great thx for viewing my question) I have some strange subject: my spring boot tests don't work. They start successfully but always throwing 403 HTTP status when making the requests to any controller I have some project with next dependencies: buildscript { ext.kotlin_version = '1.3.71' dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.71" classpath "org.springframework.boot:spring-boot-gradle-plugin:2.2.1.RELEASE" classpath "com.google.cloud.tools.jib:com.google.cloud

Spring RequestContextHolder and WebTestClient

寵の児 提交于 2020-12-04 09:25:17
问题 I'm using Spring RequestContextHolder in the controller and it works fine. But in the unit test I get java.lang.IllegalStateException using WebTestClient . Here is an example: package demo.reactive.controller; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.request.RequestContextHolder; import reactor.core.publisher.Mono;