-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add hooks for reactive reply customizations: timeout(), retry(), tag() etc. #3183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The request is not clear. Please, be more specific what is the use-case and what exactly you would like to have customized. Also, please, consider do not raise a concern against Java DSL if it really doesn't belong to that high level API. So, your requests just against DSL are confusing. Thanks for understanding |
HI @artembilan, The requirement is to set the timeout at per request level. So the application can control the timeout as per the usecase. In our case we make calls to multiple backends, based on the request type, we need to set a different timeout. As per my tests, adding a timeout to Mono in WebFluxRequestExecutingMessageHandler will actually cancel the underlying HttpConnection when the response is not received in time.
Hope this makes sense. I have requested for an enhancement in DSL, But this can be added to XML and javaConfig as well. This is a good to have feature. |
OK. Got it! I wonder if we should consider some more general solution for any possible post-response customization. More over since you say it is "per request", then it might look like this:
Which is going to be called from the This way you can apply a requested How does that sound for you? |
Hi @artembilan, Having to use transform sounds interesting. But timeout as a simple Function(Message<?>, Duration) or a simple timeout as Duration are easy to adapt. Its my thought. May be we can have a opinion from @garyrussell or @dturanski |
…tingMessageHandler.java spring-projects#3183
…-3183 # Conflicts: # src/reference/asciidoc/whats-new.adoc
…tingMessageHandler.java spring-projects#3183
HI @garyrussell , Can you please review the issue and confirm if this enhancement makes sense. This simple enhancement gives us a lot of flexibility while designing applications. Specifically where involving with varied legacy backend that are often timing out and have different SLA's |
@artembilan is more familiar with Reactor than I so I defer to him on this one. |
OK. After more "sleeping" with this I decided to accept just only a Therefore let's continue a discussion on the Pull Request! We can come back to the |
See my comment on the related PR: #3188 (comment) |
Fixes spring-projects#3183 * Introduce a `BaseReplyProducingMessageHandler` with common advices logic for target message handler * Implement `BaseReplyProducingMessageHandler` from the `AbstractReplyProducingMessageHandler` and newly introduced `AbstractReactiveReplyProducingMessageHandler` for message handlers with `Mono` replies * Introduce a `ReactiveRequestHandlerAdvice` with a `BiFunction<Message<?>, Mono<?>, Publisher<?>>` logic to apply a `Mono.transform()` operator for a returned from the handler `Mono` reply * Make `RSocketOutboundGateway` implementing an `AbstractReactiveReplyProducingMessageHandler` * Fix `WebFluxRequestExecutingMessageHandler` to return a `Mono.then()` instead of an explicit subscription - it happens downstream anyway during reply producing with a proper error handling, too * Fix `ConsumerEndpointSpec` & `ConsumerEndpointFactoryBean` to deal with an `AbstractReactiveReplyProducingMessageHandler` as well * Demonstrate `ReactiveRequestHandlerAdvice` in the `RSocketDslTests` - without `retry()` it fails
Fixes spring-projects#3183 * Introduce a `BaseReplyProducingMessageHandler` with common advices logic for target message handler * Implement `BaseReplyProducingMessageHandler` from the `AbstractReplyProducingMessageHandler` and newly introduced `AbstractReactiveReplyProducingMessageHandler` for message handlers with `Mono` replies * Introduce a `ReactiveRequestHandlerAdvice` with a `BiFunction<Message<?>, Mono<?>, Publisher<?>>` logic to apply a `Mono.transform()` operator for a returned from the handler `Mono` reply * Make `RSocketOutboundGateway` implementing an `AbstractReactiveReplyProducingMessageHandler` * Fix `WebFluxRequestExecutingMessageHandler` to return a `Mono.then()` instead of an explicit subscription - it happens downstream anyway during reply producing with a proper error handling, too * Fix `ConsumerEndpointSpec` & `ConsumerEndpointFactoryBean` to deal with an `AbstractReactiveReplyProducingMessageHandler` as well * Demonstrate `ReactiveRequestHandlerAdvice` in the `RSocketDslTests` - without `retry()` it fails
Fixes spring-projects#3183 * Introduce a `ReactiveRequestHandlerAdvice` with a `BiFunction<Message<?>, Mono<?>, Publisher<?>>` logic to apply a `Mono.transform()` operator for a returned from the handler `Mono` reply * Fix `WebFluxRequestExecutingMessageHandler` to return a `Mono.then()` instead of an explicit subscription - it happens downstream anyway during reply producing with a proper error handling, too * Demonstrate `ReactiveRequestHandlerAdvice` in the `RSocketDslTests` - without `retry()` it fails * Add `ConsumerEndpointSpec.customizeMonoReply()` for convenience * Document `ReactiveRequestHandlerAdvice` feature
Fixes spring-projects#3183 * Introduce a `ReactiveRequestHandlerAdvice` with a `BiFunction<Message<?>, Mono<?>, Publisher<?>>` logic to apply a `Mono.transform()` operator for a returned from the handler `Mono` reply * Fix `WebFluxRequestExecutingMessageHandler` to return a `Mono.then()` instead of an explicit subscription - it happens downstream anyway during reply producing with a proper error handling, too * Demonstrate `ReactiveRequestHandlerAdvice` in the `RSocketDslTests` - without `retry()` it fails * Add `ConsumerEndpointSpec.customizeMonoReply()` for convenience * Document `ReactiveRequestHandlerAdvice` feature
* GH-3183: Add ReactiveRequestHandlerAdvice Fixes #3183 * Introduce a `ReactiveRequestHandlerAdvice` with a `BiFunction<Message<?>, Mono<?>, Publisher<?>>` logic to apply a `Mono.transform()` operator for a returned from the handler `Mono` reply * Fix `WebFluxRequestExecutingMessageHandler` to return a `Mono.then()` instead of an explicit subscription - it happens downstream anyway during reply producing with a proper error handling, too * Demonstrate `ReactiveRequestHandlerAdvice` in the `RSocketDslTests` - without `retry()` it fails * Add `ConsumerEndpointSpec.customizeMonoReply()` for convenience * Document `ReactiveRequestHandlerAdvice` feature * * Fix language in docs
Affects Version(s): 5.2.3
Enhancement
Consider adding Timeout to Webflux.outboundGateway in DSL.
Mono & Flex Supports timeout. If the timeout is exposed in exposed in the Outbound Gateway, it will simplify the configuration of services in a fluent API style.
Happy to contribute if accepted for enhancement.
The text was updated successfully, but these errors were encountered: