To implement Binary Relay, we wrote a builder, that takes the input stream and and hides it inside a fake SOAP message without reading it, and wrote a formatter that takes the input stream and writes it directly to a output stream. (of course, we take a small buffer and use that to move data between two streams).
Now if you want to understand how it works, best way is to look at the code.
When you look at the code, it is important to note following. Pass through works only if no one access the content of the message. However, there are many cases where user wants to cache (e.g. logging or any other intermediate use), and we detect that and handles it. If you look at BinaryRelayBuilder.java, you will see that we create a DataHandler, hides the input stream inside the DataHandler, and passes it in. To understand how we stream the data, you should look StreamingOnRequestDataSource.java. There, if that is the last use, we just take the input stream and stream it.
If you just look at BinaryRelayBuilder.java, readAllFromInputSteam(..) method can be misleading, and the real code that does the streaming is at StreamingOnRequestDataSource.java. We do cache. But that is ONLY IF something tried to access the SOAP body, and if nothing reads the SOAP body, it is zero copy, as we pass over the input stream as it is to next code.
No comments:
Post a Comment