Hi Devs,
Here is the benefit of this feature from Axis2's perspective.
Currently, when I use Axis2 to deploy a service class as follows,
public class MTOMService {
public void useBinaryData(String username, DataHandler dataHandler) {
try {
System.out.println("Name : " + username); // line1
OutputStream out = new FileOutputStream(new File("output.zip"));
dataHandler.writeTo(out); // line2
System.out.println("Saving done!");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
the entire attachment is loaded before useBinaryData() method is called.
Therefore, when a large attachment is used execution of line 1 will
be significantly delayed.
However, when the suggested feature is implemented, stream will be read only
when it is absolutely needed (i.e., in line 2). Therefore, execution of
line1 will happen right after receiving the client request.
Enabling attachment streaming will be similar to enabling file caching
of attachments [1], an axis2.xml parameter or MessageContext property could
be used.
[1] http://axis.apache.org/axis2/java/core/docs/mtom-guide.html#a41
<http://axis.apache.org/axis2/java/core/docs/mtom-guide.html#a41>Thanks,
Sadeep
On Mon, Jul 25, 2011 at 11:46 AM, Sadeep Jayasumana
<[email protected]>wrote:
> Hi Devs,
>
> In Apache Syanpse, we have a requirement to proxy an MTOM enabled web
> service with minimum overhead. Large files (even in GB range) should be able
> to go through Synapse without running it OOM.
>
> To satisfy this requirement, Synapse should be able to forward an incoming
> SOAP message with MTOM attachments to the backend service without building
> the attachments. Synapse might read/modify the SOAP envelop but not the
> attachments. Therefore, it should be possible to stream attachments directly
> from the Synpase's client to the backend service.
>
> However, in the current implementation of AXIOM and Axis2, MTOM attachments
> are built (in memory or in a file) by SOAPMessageFormatter. This caused
> Synapse to run OOM when in the above mentioned scenario.
>
> I have come up with a fix for this. It is to introduce a
> new org.apache.axiom.attachments.impl.AbstractPart implementation which
> streams non-soap MIME parts without building them.
>
> To introduce this new feature without breaking existing stuff, I'm planning
> to introduce a new message context property which enables MTOM streaming.
> org.apache.axis2.builder.BuilderUtils class will check this property in the
> message context and create org.apache.axiom.attachments.Attachments
> object accordingly. Does this sound like the correct way of introducing this
> feature?
>
> Appreciate your feedback.
>
> Thanks,
> --
> Sadeep Jayasumana
> Software Engineer,
> WSO2 Inc.
>
>
--
Sadeep Jayasumana
Software Engineer,
WSO2 Inc.