I have developed an application, in which file is stored on fileserver (customised). There are two web services communicating with each other. 'WebServiceA' and 'WebServiceB'. on two different machines.
WebServiceB stores/get the file on/from fileServer on WebServiceA's call.
when client wanted to download the file, he calls WebServiceA's method. WebServiceA calls the WebServiceB's download method. I have enabled MTOM and StreamingAttachment as my files are quite large, some are 4KB and some are upto 2GB size. My WebMethods step on WebServiceB are Get File on local machine from FileServer (which is on different machine). Create DataHandler from FileDataSource by passing file as a parameter. return the DataHandler object to WebServiceA's method.
The problem is that, after some operations the WebServiceB's local machine's stores large number of files which were created during the download operation.
I tried 1) delete the file in finally block in WebServiceB, which results in to null file on WebServiceA
2) create a temporary file. temp = File.createTempFile("temp", ".txt"); temp.deleteOnExit(); but that wont delete, as my webserviceB never going to be down.
3) and i can not implement 'acknowledgement' between WebServiceA to WebServiceB or 'delete on time interval' as my manager rejected the solution.
Is there any genine solution present in java which tells me file is currently not consumend by anybody.
All my machines runs on freebsd 8.2, java6, glassfish 3.1 and jaxws 2.2.