aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How can I return Stream from Session bean ???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How can I return Stream from Session bean ????" Watch "How can I return Stream from Session bean ????" New topic
Author

How can I return Stream from Session bean ????

Andrey Solonchuk
Greenhorn

Joined: Mar 29, 2003
Posts: 4
How can I return Stream from Session bean ???
I try to create an array with data and return it? but
its not good idea becouse some times i
have exeption out of memory .
thanks beforehand.

Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
It is not a good idea to return streams from EJBs. Most streams are not serializable (which doesn't really matter if you use local interfaces) and you don't want to keep certain resources open longer than necessary or leave them possibly unclosed. In general, you are asking for trouble if you go this route.
What exactly are you passing around that is using so much memory? Quite possibly, EJB may not be a good solution in this particular case...
Andrey Solonchuk
Greenhorn

Joined: Mar 29, 2003
Posts: 4
yes, may be i`m wrong using EJB for this task
I have server(j-boss) with has connection thru jdbc to database,
i need build report client side, for this i need data as resul ot query to data base
so i see it as a pipe between client and database
i`ll only get whoe result of query ( only moving forvard geting data) and build report using xslt
i think about, may be i heed somethink like httpsession.....
Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
    
    1
Is there a streaming solution to this?

I have remote clients that accesses SLSB to download binary files from a CMS. The server will run out of memory if there are too many concurrent client requests, or if some of the files are too large.

I prefer not to use servlets, any other J2EE solutions that can do streaming?
[ September 05, 2007: Message edited by: Chu Tan ]
Kedar Bhawarthi
Greenhorn

Joined: May 14, 2004
Posts: 8
How about emulating Stream interface with statefull session bean?

It is true that we are shifting some client responsibility on server side (like closing stream, eating data chunk by chunk etc) but it think it more reliability in tread offs.

We should assume that client will sincerely consume data ASAP and will release our bean. Notably overhead of keeping statefull beans is not going to be much considering java implementation of streams.
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Isnt it possible over here to create a Data object out of the result set and return that from the session bean?
You can implement a paging logic on the data object if the data is too huge and your client can afford to do so.
I think it will be an overkill to build a streaming solution for this sort of a thing. Having a data object with paging(fetch data on demand) will be more suitable.


apigee, a better way to API!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can I return Stream from Session bean ????