Skip to content
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

Method writeAndFlushWith(body) is not invoked in ClientHttpRequestDecorator when doing a @POST call with request @Body Flux using @RetrofitClient with WebClient #50

Open
dante-ricalde opened this issue Jun 16, 2022 · 0 comments

Comments

@dante-ricalde
Copy link

dante-ricalde commented Jun 16, 2022

Hi guys, @OlgaMaciaszek
I am trying to implement a decorator to ClientHttpRequestDecorator to print some logs using @RetrofitClient @Body with Flux for the request body using WebClient, but it is not working. The method writeWith(body: Publisher) of the decorator is being invoked (actually this method should have been invoked: writeAndFlushWith()) and it doesn't receive correctly the data buffers causing the logs are not printed correctly, only the text {"prefetch":-1} is printed as request body.

I am trying with the following Retrofit Client:

    @Headers(*["Content-Type: application/stream+json", "Accept: application/stream+json"])
    @Streaming
    @POST("cards/search-stream")
    fun searchStream(@Body cardsSearchAllRequest: Flux<Card>): Flux<Card>

Note:
The method writeAndFlushWith() is being invoked and works correctly when an http request is invoked directly using WebClient (but We would like to use the component @RetrofitClient and not just the WebClient directly), like this:

    val webClient =
    WebClient.builder().baseUrl("http://localhost:8082/support/cards/v1").defaultHeader("Content-Type", "application/stream+json").clientConnector(
            DefaultReactorClientHttpConnectorDecorator(
                    ReactorClientHttpConnector(HttpClient.create()), { -> true}))
            .build()
    return webClient
            .post()
            .uri("/cards/search-stream")
            .header(org.springframework.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_STREAM_JSON_VALUE)
            .header("caller-name", "web-client")
            .header("Request-ID", "550e8400-1234-41d4-a716-446655440025")
            .body(Flux.just(Card("a", "b"), Card("c", "d"), Card("e", "f"), Card("g", "h")), Card::class.java)
            .retrieve()
            .bodyToMono(Card::class.java);

We want to know if there is a bug for this scenery or there is not still support for making this type of call: @post call with request @Body Flux using @RetrofitClient(WebClient)?

I am looking forward to hearing from you!

@dante-ricalde dante-ricalde changed the title method writeAndFlushWith(body) is not invoked in ClientHttpRequestDecorator when doing a @POST call with @Body Flux using @RetrofitClient with WebClient method writeAndFlushWith(body) is not invoked in ClientHttpRequestDecorator when doing a @POST call with request @Body Flux using @RetrofitClient with WebClient Jun 16, 2022
@dante-ricalde dante-ricalde changed the title method writeAndFlushWith(body) is not invoked in ClientHttpRequestDecorator when doing a @POST call with request @Body Flux using @RetrofitClient with WebClient Method writeAndFlushWith(body) is not invoked in ClientHttpRequestDecorator when doing a @POST call with request @Body Flux using @RetrofitClient with WebClient Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant