Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
When integrating with any asynchronous IO we are obligated to implement flow control based on the capacity of the Transport.
Things get especially harder because when you pop bytes in a asynchronous method for after completion:
e.g. on Netty:
channel.writeAndFlush(bytes).addListener(new ChannelFutureListener()
{
@Override
public void operationComplete(ChannelFuture future) throws Exception
{
transport.pop(bufferSize);
/// perform process, and dispatch!
performDispatchEtc();
if (transport.capacity() > 0)
}
});
this makes things specially harder as we are eventually losing events or bytes. We could make things work with some hacks (like having recursive loops on the methods for writing and reading)...
Making Proton-J to work with asynchronous pop is definitely a black art. Instead of working around with recursive workarounds we should provide an easier path. such as plugging SessionFlowController where we could activate / deactivate producers on a server, or use Semaphores on a client where a client could block until things are properly released.