Hi,
IMO the CarbonCallback.done() implementation should be non blocking to be
async. But the current implementation of CarbonCallback.done() in carbon
transport is blocking.
Because of this, it's hard to stream responses. For example, in MSF4J, when
sending chunked responses, as soon as we fill the headers of the response
carbon-message, we should be able to send it while the body is not yet set.
Later, we should be able to add body content to the carbon-message to be
sent as chunks. Consider the following pseudo code for this scenario.
CarbonMessage response = initResponse()
response.setHeaders() // all headers are set. Body is not yet ready
carbonCallback.done(response); // start sending the response that has all
headers.
while(condition){
chunk = read()
response.addBoaddMessageBody(chunk) //send content chunks without
loading the complete content into memory (may be of a large file)
}
If we do this with the current transport implementation (2.0.*) of the
CarbonCallback, there will be a deadlock at
carbonCallback.done(response) because
of the internal blocking queue that waits until all the message bodies
arrive.
IMO CarbonCallback.done() should immediately return a future object without
blocking. And the CarbonCallback.done() operation should happen internally
in a different thread.
WDYT?
Best Regards,
Samiyuru
--
Samiyuru Senarathne
*Software Engineer*
Mobile : +94 (0) 71 134 6087
[email protected]
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture