day_dreamer
day_dreamer

Reputation: 834

download of a large file from webservice causing application performance issue

I have gone through the previous posts and similar questions were asked but I couldn't find a solution to my problem. In my application user can download the files, So when user clicks on download our application server internally set's up the authenticated session with the web service which send the file data in the XML response as below :

<FileSerial xmlns="http://my.example.com/webservices">
  <filedata>base64Binary</filedata>
  <filesize>int</filesize>
  <filetype>string</filetype>
  <mime_type>string</mime_type>
</FileSerial>

And I have used spring-ws as below :

 GetDocResponse docResponse = (GetDocResponse) webServiceTemplate.marshalSendAndReceive(getDoc);
FileSerial fileSerial = docResponse.getGetDocResult();
fileByte = fileSerial.getFiledata();

After several users hit the download our application server JVM memory goes very high and application server doesn't respond and have to be restarted. My guess is that the fileByte is stored in my application server memory and that's causing the issue.

Is there any way to stream directly into the client browser without storing it in the application server memory.

Any sample code will be of help.

Upvotes: 2

Views: 881

Answers (1)

Javier Toja
Javier Toja

Reputation: 1762

You are loading the full doc on your heap, plus the conversion to base64. If you don't use copy by reference every map from your binary data to other object is creating another entry on your heap.

You should use a multi part request and send the doc as an attachment of your ws request MTOM example

Upvotes: 1

Related Questions