vert-x3 / vertx-tcp-eventbus-bridge

Apache License 2.0
50 stars 44 forks source link

Create backpressure handler for TcpEventBusBridgeImpl #69

Open erik777 opened 2 years ago

erik777 commented 2 years ago

Primarily need this for client consumer events. With large messages over slow connections, the client can be slow. The backlog could build up on the bridge server.

Currently, there is no apparent backlog. It just does a write without checking writeQueueFull() or setting drainHandler.

FrameHelper#writeFrame:

handler.write(Buffer.buffer().appendInt(data.length).appendBytes(data));

Ideally, this could be configured to set a max queue depth and a policy of dropping messages when hit to protect the server from unbounded ram usage.

Please let me know if there is a way to do this today w/o changing the code.

erik777 commented 2 years ago

I resolved without directly adding backpressure, but, rather, just adding another checkCallHook inside the consumer of the "registger" case in TcpEventBusBridgeImpl. I used the BridgeEventType.RECEIVE type since it was not being used on the server and its doc described it as "delivered from the server to the client".

I'd like to create a PR to bring this into the normal continued release of the bridge. I'm open to changing things. Please peer review at this fork and comment or let me know if you'd like a PR or if you'd like to see changes:

https://github.com/Acuity-vct/vertx-tcp-eventbus-bridge

Through this new bridge event we were able to successfully add backpressure handling in our project using the handler.

erik777 commented 2 years ago

Resolved this issue with this PR

https://github.com/vert-x3/vertx-tcp-eventbus-bridge/pull/71