Spring reactive Webclient timeout - spring

I was trying to test the default timeout of Spring reactive Webclient .
For that purpose I created a rest endpoint that takes 10 hours to return a response.
I created a rest client using spring reactive Webclient. But I see that the spring Reactive Webclient keeps waiting for 10 hours.
Doesn't spring reactive Webclient has any default timeout?

If you are using Reactor Netty as HTTP client library which is default using Spring WebFlux there is no default response timeout specified. If you would like to configure timeout settings there are multiple options as described in the Projectreactor reference documentation chapter 6.14.

Related

How can i set timeout for individual rest calls in spring boot?

I am using spring boot starter web for rest api methods. I need to set custom timeout for individual rest calls. How is it possible ?
Similarly I am using feign clients, I would like to set timeout for individual feign methods also.

Does Spring WebFlux automatically close connections when using .retrieve() or .exchange()?

We recently switched from a JAX RS-based WebClient to Spring's reactive WebFlux client. As we had problems with the old client retaining connections in some cases, we were wondering how the WebFlux client treats those. Unfortunately, Spring's documentation for WebFlux doesn't provide details on this, only in the context of WebSockets. So: Does calling .retrieve() or .exchange() automatically close connections? Or do we need to take care of that on our own?

How to handle HTTP 429 in my Spring Boot App?

My Spring Boot application uses a REST endpoint.
This endpoint returns a HTTP 429 (too many requests) at high load.
What is the best way to handle it?
Does Spring Boot offer possibilities here?
It depends on which version of spring you use.
If you use reactive streams (e.g. webFlux framework) then you can use backpressure mechanism.
If not, you can use for example resilience4j ratelimiter and bulkhead mechanism.

Can I consume a non-reactive REST API service using the Spring 5 WebFlux WebClient?

I have a written a microservice using Spring 5 WebFlux and trying to consume a non-reactive REST API through it. Is it possbile to consume a non-reactive service using a reactive webclient?
Yes, this is possible. From the server's point of view, this is just a regular HTTP client. WebClient does support streaming and backpressure, but this doesn't change things at the HTTP level.
The backpressure is dealt with at the TCP flow-control level, so the HTTP protocol stays the same.

Using Gateway to consume Spring Boot application from Spring Integration application

I am just starting with Spring Integration with Spring Boot 2.
I am working on a application which uses Spring Integration's HTTP outbound gateway to consume a Spring boot Service.
I am consuming the spring boot service from Spring Integration application using Gateway.
When I call the Gateway method which in turn will use the outbound gateway to call the spring boot service, the request does not seem to be completed. It is just going on when I make the HTTP GET request via the browser.
The request is also not received by the Spring Boot service.
I am not able to identify what is wrong in my Integration application when using gateway to consume a Spring Boot 2 service.
I have shared my Spring Boot 2 Application and also the Integration application which I am using to consume it in the below github folder. it contains 2 folders, one for the spring Integration application and the other for the spring boot application.
https://github.com/gsamartian/spring-int-demos
I have exposed a REST interface for the Integration application using RestController.
I access the boot application from integration application via the url, http://localhost:8763/callExternalServiceViaGateway
I am able to access the spring boot application directly from its port.
If anyone can help me identify the cause it would be great.
Thanks,
Your problem that the gateway method is without any args:
#Gateway(requestChannel = "get.request.channel", replyChannel = "reply.channel")
String getCustomMessage();
In this case the gateway works as receiving. No any requests is send because nothing to wrap to the payload. See more info on the matter in the Reference Manual.
Right now I see several bugs with the payloadExpression and no arg, so I suggest you to add some String payload arg to the getCustomMessage() gateway method and perform it with an empty string.
Will take a look into the bugs and will fix them soon.
Thank you for a good sample how to catch and reproduce!
https://jira.spring.io/browse/INT-4448
https://jira.spring.io/browse/INT-4449

Resources