[jboss-user] [EJB 3.0] New message: "EJB3 slower than EJB2"
No Name
do-not-reply at jboss.com
Fri Jan 29 09:35:00 EST 2010
User development,
A new message was posted in the thread "EJB3 slower than EJB2":
http://community.jboss.org/message/523003#523003
Author : No Name
Profile : http://community.jboss.org/people/ekric
Message:
--------------------------------------------------------------
Hi everybody,
im currently working on an Migration Project from EJB2 to EJB3. Now I'm doing some testing and this problem is driving me crazy.
I'm using JBoss 5.1.0.GA and an Oracle Database Version 11g.
In the each Session Bean I have a method who is doing a create. And the task is to do a create 10000 times in a row. Once in EJB2 (old Version) once in EJB3 (new version). And to my suprise the EJB2-create-Method is nearly twice as fast: *31 Seconds in EJB2 compared to 67 Seconds in EJB3. How is that?* I've tried a lot of things: Changed Transaction Types, Tested JBoss 6, etc.
What is interesting: I've mesured the Data going from the Client to the Server and back. Result: The Data beeing received by the Client is nearly the same. But the Data beeing send to the server, during the process, is aprox. double! When I use a local JBoss Server an the remote Oracle Database, the Process is getting faster in EJB3. Makes sense. Can you tell me why the amount of Data is so different? Is there so much more Overhead in EJB3?
I have a very simple testing example in EJB3: Remote Interface -> Session Bean -> Entity Bean.
I'm using a JUnit Test-Case which does the following in each Version (2/3):
+/**
*
* @throws Exception
*/
public void testCreateEJB3() throws Exception {
+ +EntityBean bean = new EntityBean();+
+ for (int i = 0; i < id_neu.length; i++) {
id_new[i] = Remote.++createBean++(++bean++);
}
}+
"id_new.lenght" is 10000.
*This is the create-Method:*
+ at Stateless
++public class ...Bean$$$ implements ...Remote$$$ {+
+ @PersistenceContext
EntityManager em;+
+ public Integer createBean() {
Integer number = new Integer(1);
EntityBean bean = new EntityBean();+
+ if (this.selectMaxID() == null) {
number = 1;
} else {
number = this.selectMaxID().intValue() + 1;
}+
+ bean.setId(number);+
+ em.persist(bean);
bean.setBLocked(true);
return bean.getId();
}+
+ ...+
+}+
*The selectMaxID-Method. It gets the smallest possible ID from the Database.*
+public Integer selectMaxID() {
Query query = em
.createQuery("SELECT max(u.id) FROM xyz u");
Integer maxID = (Integer) query.getSingleResult();
return maxID;
}+
So to the EJB2 Version: There is a Delegate-Class who uses a Session Facade Bean and the "Dto"-Pattern-Object to create the Entity...
+public Integer createBean(xyzDto+ +xyz++Dto) throws EJBException {
Integer nPrimaryKey;
if (xyzDto == null) {
}
try {
+ +Xyz+ +xyz+ += xyzHome.create();
setXyzFromXyzDto(++xyz++,+ +xyz+Dto+);
nPrimaryKey = new Integer(((Integer)+ +xyz++.getPrimaryKey()).intValue());
+ +xyz++.setBLocked(true);
} catch (Exception e) {
throw new EJBException(e.getMessage());
}
return nPrimaryKey;
}+
... and in the ejbCreate of the Entity there is the same "selectMaxID" (same SQL Statement) as mentioned before.
+public Integer ejbCreate() throws CreateException {
Integer number = new Integer(1);
try {
+ +number+ += this.ejbSelectMaxID().intValue() + 1;
} catch (Exception e) {
}
setId(++number++);
return null;
}+
I hope you have any ideas why the new Version is so slow. I'm sorry if I forgot to provide any data or if this post is in the wrong format.
Thank you.
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/523003#523003
More information about the jboss-user
mailing list