I need to send a blob binary stream using ServletOutputStream.
I use the following technologies and software: Oracle 11, WebSphere 7, Springframework 2.5.5, Hibernate 3.3.SP1.
There are two Oracle databases. The first contains tables for describing the documents that I must transmit, and the second contains the contents of the documents.
I also set up support for XA data sources in WebSphere and JtaTransactionManager in spring.
I get a link to the document itself and the content in one transaction.
The JDBC specification tells us that LOBs are transactional objects, and portable applications should use such objects in transactions.
And I have the following questions:
- Is it legal to receive a BLOB input stream in a transactional method and pass it to the top-level non-transaction method? Something like that:
@Transactional
public InputStream getContent(Long docId) {
Blob blob = getBlob(...);
return blob.getBinaryStream();
}
public ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse resp) {
Long docId = ServlerRequestUtils.getRequiredLongParameter(req);
InputStream is = service.getContent(docId);
copy(is, resp.getOutputStream());
return null;
}
If this is not legal, how can I transfer the BLOB binary stream to the end user, if the BLOB content is large enough and the application server has a pre-configured transaction timeout? Should I process transactions manually and set the timeout to zero (transaction never ends)?
What is the best way to transmit the BLOB binary stream to the end user in this case?
szhem source
share