Have you looked at the reactive extensions for HttpCore5? They demonstrate how to implement AsyncEntityProducer/AsyncDataProducer with support for backpressure (or you can just use the Reactive Streams API instead):
https://github.com/apache/httpcomponents-core/tree/master/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive On Fri, Sep 6, 2019 at 9:33 AM Roy Hashimoto <roy.hashim...@gmail.com> wrote: > I'm playing with asynchronous handlers in HttpCore 5, and I'd like to have > an AsyncEntityProducer write data at its own (slow) rate like in this old > thread <https://marc.info/?l=httpclient-commons-dev&m=134928851229305&w=2 > >. > Writing to the DataStreamChannel whenever I want - outside the scope of a > produce() method call - works fine, but I notice that produce() is being > called every 5-6 milliseconds which ideally I would like to eliminate or > reduce. > > The answer in the old thread was to use IOControl.suspendOutput() and > IOControl.requestOutput(), but this class appears no longer to be in > HttpCore 5. I see that there is a DataStreamChannel.requestOutput() but I > haven't figured out what suspension call that should be paired with. I have > tried simply returning 0 from my AsyncEntityProducer.available() override, > but that doesn't seem to be it. > > Is there a new way to suspend/resume output in HttpCore 5? > > Thanks! > Roy > > Kotlin source here > <https://gist.github.com/rhashimoto/1f5501d3b5d2aa95251fe12f4f0be250>. >