 |
|
|
|
|
Member
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
Join Date: Jan 2009
|
JavaEE EJB. How to send large data to JavaSE client -
07-30-2009, 07:13 AM
I plan to write some kind of reporting application using EJB3 technology. But specific of this application is to generate and send huge amount of data to client. If I understand EJB right it serialize java object in some way and then sends it to client. For example if I make fetch from database I do not want to fetch all data and then send it to client. I want fetch first 10 records and then send it, then fetch another 10 and so on. Also client must have option to cancel fetch.
I can do it using servlet without any problems. I just can, for example, use Stream and send to client everything I want. But how I can do it using EJB?
As I see possible solution is to create statefull session bean, on session create open cursor on database side and upon consequent requests from client fetch by 10 row at once till the EOF
So my question is about application design. Is it right way to use EJB statefull bean?
|
|
|
|
|
Member
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Join Date: Jul 2009
|
Yes, this is fine. -
07-30-2009, 08:31 AM
Yes, this is fine using EJB @Remote and @Stateful. Indeed, things would probably scale much better because of RMI vs. HTTP, pooling, passivation, etc as compared with Servlets.
You can even try JPA query paging via setFirstResult/setMaxResults besides trying to use a cursor yourself. Also, it might be worth trying to push all the data at once. RMI can be surprisingly robust/performant handling large amounts of data over the network. Unlike Servlets, there are no HTTP timeouts to deal with in RMI.
Hope it helps,
Reza
|
|
|
|
|
The Following User Says Thank You to rrahman For This Useful Post:
|
|
|
Member
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Oct 2009
|

10-08-2009, 08:24 AM
Hi:
My experience is not to use EJBs for reporting since reporting per se spans across multiple data domain and hence is effeciently handled using a servlet and backend database.
Possible implementation:
Use a map and store it in Session object and show records only on demand. Hope it helps, my 2 cents
regards
--Sabarish
|
|
|
|
|
Member
Posts: 19
Thanks: 0
Thanked 1 Time in 1 Post
Join Date: Jan 2008
Location: Germany, Munich
|

10-09-2009, 12:07 PM
EJBs can also be used for reporting. There is no advantage of having a servlet which handles the diffrent databases. This can also be done with ejbs and the diffrent domain-objects (and, you can also have native sql-queries if you need them).
The problem is the large amount of data. In this case I would use an ejb to invoke the reporting process and deliver the results using jms. Then the successfully computed parts can be deliverd when they'll be ready.
The SFSB example with the cursor looks good but the problem is the lifecycle in many applicationservers the connection will be given back to the pool when the SFSB is passivated. So you can't handle the cursor-way with these applicationservers.
From my point of view I would prefer the way to invoke the reporting-process and deliver the results using jms.
yours
marc
Ceterum censeo Carthaginem esse delendam.
|
|
|
|
|
Member
Posts: 19
Thanks: 0
Thanked 1 Time in 1 Post
Join Date: Jan 2008
Location: Germany, Munich
|

10-09-2009, 12:07 PM
EJBs can also be used for reporting. There is no advantage of having a servlet which handles the diffrent databases. This can also be done with ejbs and the diffrent domain-objects (and, you can also have native sql-queries if you need them).
The problem is the large amount of data. In this case I would use an ejb to invoke the reporting process and deliver the results using jms. Then the successfully computed parts can be deliverd when they'll be ready.
(and you can implement a cancel-operation, which you can't having a servlet or a simple ejb-call)
The SFSB example with the cursor looks good but the problem is the lifecycle in many applicationservers the connection will be given back to the pool when the SFSB is passivated. So you can't handle the cursor-way with these applicationservers.
From my point of view I would prefer the way to invoke the reporting-process and deliver the results using jms.
yours
marc
Ceterum censeo Carthaginem esse delendam.
|
|
|
|
|
Member
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Join Date: Jul 2009
|
Seems to be an EJB 2 specific comment -
10-14-2009, 04:43 PM
Sabarish,
Your experience appears to be EJB 2.x entity beans specific. As mende mentions, cross domain mappings are not really that big of a deal with EJB3/JPA.
Cheers,
Reza
|
|
|
|
|
Moderator
Posts: 99
Thanks: 0
Thanked 8 Times in 8 Posts
Join Date: Feb 2008
|

10-15-2009, 07:58 AM
As you should never send ResultSet and other jdbc entities using EJBs, there's no problem. The resulting data should be translated into something that can be sent, usually some form of POJO.
EJB Entity beans (or preferably the newish EJB3 entities) take care of that for you.
|
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|