Git Product home page Git Product logo

Comments (9)

Akshay-Sundarraj avatar Akshay-Sundarraj commented on June 1, 2024 1

@violetagg Thanks for the reply. I'll try to update the code as suggested by you.

from reactor-netty.

violetagg avatar violetagg commented on June 1, 2024

@Akshay-Sundarraj You should always defer the creation of the buffers. Something like this:

    static Mono<String> execute(HttpClient httpClient, String uri) {
        return Mono.defer(() -> {
            return Mono.defer(() -> {
                return httpClient.request(HttpMethod.POST)
                        .uri(uri)
                        .send((httpClientRequest, nettyOutbound) -> {
                            return nettyOutbound.send(Mono.create(sink -> {
                                ByteBuf buffer = ByteBufAllocator.DEFAULT.directBuffer();
                                buffer.writeBytes("Hello World".getBytes(StandardCharsets.UTF_8));
                                sink.success(buffer);
                            }));
                        }).responseSingle(((response, byteBufMono) -> {
                            return byteBufMono.asString();
                        }));
            }).doFinally(signalType -> {
            });
        });
    }

from reactor-netty.

Akshay-Sundarraj avatar Akshay-Sundarraj commented on June 1, 2024

@violetagg Thanks for the suggestion. The thing is I need to fill the buffer with some binary values based on some binary protocol somewhere else and filling the buffer(serialising some objects) may throw errors. Basically buffer is created and filled in some other part. Is there any way I can handle this?

from reactor-netty.

violetagg avatar violetagg commented on June 1, 2024

@Akshay-Sundarraj I cannot help with creating the reactive pipeline as I do not know your project.

from reactor-netty.

Akshay-Sundarraj avatar Akshay-Sundarraj commented on June 1, 2024

@violetagg My question is reactor netty release buffer in some cases and does not release is some other cases. How can I know in what scenarios it doesn't relases?

from reactor-netty.

violetagg avatar violetagg commented on June 1, 2024

@Akshay-Sundarraj If we receive the buffer we will definitely release it, however here the HttpClient doesn't start sending at all as it cannot obtain a connection from the pool. That said the buffer consumption is lazy, we will not obtain the buffer as a first step. As a first step we need a connection that will be used for sending the request. Because of that you have to create the buffer only if there is a subscriber that will consume it, while now you create the buffer always regardless whether there is a subscriber or not.

from reactor-netty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.