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

require for documentation around how backpressure works #612

Open
cytnju opened this issue Jul 19, 2018 · 4 comments
Open

require for documentation around how backpressure works #612

cytnju opened this issue Jul 19, 2018 · 4 comments

Comments

@cytnju
Copy link

cytnju commented Jul 19, 2018

I want to lean how backpressure works in RxNetty.
Could you please provide such documentation as you mentioned in FAQs?
I would appreciate it if you can help me

@cytnju
Copy link
Author

cytnju commented Jul 19, 2018

I know that BackpressureManagingHandler may help controll the flow in write aspect,but how it works in read aspect?

@cytnju
Copy link
Author

cytnju commented Jul 19, 2018

and I want to know How to use this feature when I want to add a ChannleHandler to the pipeline.
this way?
image
or this way?
image

@cytnju
Copy link
Author

cytnju commented Jul 20, 2018

@jamesgorman2 would you please do me a favor?

@jamesgorman2
Copy link
Collaborator

Hi cynthju, answers below

BackpressureManagingHandler

I didn't write this, so I'm going on my reading of it and my best understanding of TCP.
For reading BackpressureManagingHandler delegates its behaviour to AbstractConnectionToChannelBridge.ReadProducer which is an RxJava producer tha handles the backpressure. It will tell BackpressureManagingHandler if it has active read requests, which will pass that to Netty. I guess this then uses native TCP behaviour to tell the writer to stop sending once the local receive buffer is full.

ChannelHandler
In this instance the behaviour is identical. The first will always add a new THandler to all connections. If the second can be set up to do it only to some connections, eg:

    TcpServer<ByteBuf, ByteBuf> s = TcpServer.newServer()
      .start(
        newConnection ->
          Math.random() < 0.5 ?
            newConnection.addChannelHandlerLast("TestHandler",new THandler()).ignoreInput() :
            newConnection.ignoreInput()
      );

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

2 participants