Can't get read-ahead load-group working on AS7 for EJB2.1
vquartara Feb 26, 2015 1:17 PMHi everybody,
I'm migrating an old J2EE application from Websphere5 to JBossAS 7.2.0Final.
Everything is working so far, but after the first load tests I realized the need to do some tuning on the CMP engine, since JBoss executes too many queries in some situations.
I couldn't find any detailed doc in the official guide (https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/html/Administration_and_Configur…) so I followed the instructions found here 12.7. Optimized Loading
But JBoss totally ignores my configuration, although the application start up and run correctly.
Can anyone suggest me how to fine-tuning the CMP engine the version of JBoss I'm using?
Following details of my configuration:
from ejb-jar.xml
<entity id="PatternURL">
<ejb-name>PatternURL</ejb-name>
<local-home>it.visura.bke.business.navigazione.ejb.model.PatternURLLocalHome</local-home>
<local>it.visura.bke.business.navigazione.ejb.model.PatternURLLocal</local>
<ejb-class>it.visura.bke.business.navigazione.ejb.model.PatternURLBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>it.visura.bke.business.navigazione.ejb.model.PatternURLKey</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>PatternURL</abstract-schema-name>
<cmp-field>
<field-name>idPatternURL</field-name>
</cmp-field>
<cmp-field>
<field-name>patternRegEx</field-name>
</cmp-field>
<cmp-field>
<field-name>tipo_comportamento</field-name>
</cmp-field>
<cmp-field>
<field-name>caseInsensitiveMatching</field-name>
</cmp-field>
<ejb-local-ref>
<ejb-ref-name>ejb/ConfigPatternSostituzioneURL</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>it.visura.bke.business.navigazione.ejb.model.ConfigPatternSostituzioneURLLocalHome</local-home>
<local>it.visura.bke.business.navigazione.ejb.model.ConfigPatternSostituzioneURLLocal</local>
<ejb-link>ConfigPatternSostituzioneURL</ejb-link>
</ejb-local-ref>
<ejb-local-ref>
<ejb-ref-name>ejb/ServizioUtente</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>it.visura.bke.business.navigazione.ejb.model.ServizioUtenteLocalHome</local-home>
<local>it.visura.bke.business.navigazione.ejb.model.ServizioUtenteLocal</local>
<ejb-link>ServizioUtente</ejb-link>
</ejb-local-ref>
<query>
<description></description>
<query-method>
<method-name>findPatternsForServizioUtente</method-name>
<method-params>
<method-param>int</method-param>
</method-params>
</query-method>
<ejb-ql>select object(o) from PatternURL o where o.srvutente.idServizioUtente = ?1</ejb-ql>
</query>
</entity>
from jbosscmp-jdbc.xml
<entity>
<ejb-name>PatternURL</ejb-name>
<load-groups>
<load-group>
<load-group-name>caricaPatternURL</load-group-name>
<field-name>patternRegEx</field-name>
<field-name>caseInsensitiveMatching</field-name>
<field-name>tipo_comportamento</field-name>
<!-- <field-name>patsost</field-name> -->
</load-group>
</load-groups>
<eager-load-group>caricaPatternURL</eager-load-group>
<read-ahead>
<strategy>on-find</strategy>
<page-size>10</page-size>
<eager-load-group>caricaPatternURL</eager-load-group>
</read-ahead>
</entity>
the code:
PatternURLLocalHome homePattern = null;
try {
homePattern = (PatternURLLocalHome) Utils.getHomeForPOJO(JNDI_REF_PATTERN_URL);
} catch (NamingException e) {
// checked system error: si rigetta come EJBException dopo averlo loggato
throw ExceptionLogUtil.createLoggedEJBException(e, log);
}
Collection listUrlPattern = null;
try {
listUrlPattern = homePattern.findPatternsForServizioUtente(this.idServizioUtente);
if (listUrlPattern == null || listUrlPattern.size() == 0) return;
} catch (FinderException e) {
log.warn(e);
return;
}
Collection listaURLdaSostituire = new ArrayList();
short counter = 0;
for (Iterator iter = listUrlPattern.iterator(); iter.hasNext();) {
PatternURLLocal ejbPattern = (PatternURLLocal) iter.next();
int idPattern = ((PatternURLKey) ejbPattern.getPrimaryKey()).idPatternURL;
String regEx = ejbPattern.getPatternRegEx();
boolean caseInsensitiveMatching = ejbPattern.getCaseInsensitiveMatching();
if (ejbPattern.getTipo_comportamento() == CostantiNavigazione.PATTERN_URL_TIPO_SOSTITUZIONE_URL) {
ConfigPatternSostituzioneURLLocal ejbConfigPatternSostituz = ejbPattern.getPatsost();
if (ejbConfigPatternSostituz != null) {
PatternSostituzioneURL patternURL = new PatternSostituzioneURL(idPattern, regEx, caseInsensitiveMatching);
patternURL.setContentType(ejbConfigPatternSostituz.getContentType());
patternURL.setSostituisciRifAssoluti(ejbConfigPatternSostituz.getSostituisciRifAssoluti());
patternURL.setTipoSostituzioneURL(ejbConfigPatternSostituz.getTipoSostituzioneURL());
patternURL.setDominioDaSost(ejbConfigPatternSostituz.getDominioDaSostituire());
patternURL.setNumPortaDaSost(ejbConfigPatternSostituz.getNumPortaDaSostituire());
patternURL.setProtocolloUrlDaSost(ejbConfigPatternSostituz.getProtocolloDaSostituire());
patternURL.setStessiParametriBD(ejbConfigPatternSostituz.getStessiParametriBD());
patternURL.setUrlDaSostituire(ejbConfigPatternSostituz.getUrlDaSostituire());
listaURLdaSostituire.add(patternURL);
counter++;
}
}
}
the log:
13:19:57,042 DEBUG [org.jboss.as.cmp.jdbc.JDBCEJBQLQuery.PatternURL#findPatternsForServizioUtente] Executing SQL: SELECT t0_o.idPatternURL, t0_o.patternRegEx, t0_o.tipo_comportamento, t0_o.caseInsensitiveMatching, t0_o.SRVUTENTE_IDSERVIZIOUTENTE FROM PATTERNURL t0_o LEFT OUTER JOIN SERVIZIOUTENTE t1_o_srvutente ON t0_o.SRVUTENTE_IDSERVIZIOUTENTE=t1_o_srvutente.idServizioUtente WHERE t1_o_srvutente.idServizioUtente = ?
13:19:57,044 DEBUG [org.jboss.as.cmp.jdbc.JDBCEJBQLQuery.PatternURL#findPatternsForServizioUtente] param: i=1, type=INTEGER, value=1
13:20:12,045 DEBUG [org.jboss.as.cmp.jdbc.JDBCLoadEntityCommand.PatternURL] Executing SQL: SELECT patternRegEx, tipo_comportamento, caseInsensitiveMatching, SRVUTENTE_IDSERVIZIOUTENTE FROM PATTERNURL WHERE (idPatternURL=?)
13:20:40,822 DEBUG [org.jboss.as.cmp.jdbc.JDBCLoadEntityCommand.PatternURL] Executing SQL: SELECT patternRegEx, tipo_comportamento, caseInsensitiveMatching, SRVUTENTE_IDSERVIZIOUTENTE FROM PATTERNURL WHERE (idPatternURL=?)
13:20:42,839 DEBUG [org.jboss.as.cmp.jdbc.JDBCLoadEntityCommand.PatternURL] Executing SQL: SELECT patternRegEx, tipo_comportamento, caseInsensitiveMatching, SRVUTENTE_IDSERVIZIOUTENTE FROM PATTERNURL WHERE (idPatternURL=?)
13:20:44,471 DEBUG [org.jboss.as.cmp.jdbc.JDBCLoadEntityCommand.PatternURL] Executing SQL: SELECT patternRegEx, tipo_comportamento, caseInsensitiveMatching, SRVUTENTE_IDSERVIZIOUTENTE FROM PATTERNURL WHERE (idPatternURL=?)
13:20:44,505 DEBUG [org.jboss.as.cmp.jdbc.JDBCLoadRelationCommand.PatternURL] load relation SQL: SELECT patternurl_idPatternURL FROM CONFIGPATTERNSOSTITUZIONEURL WHERE (PATTERNURL_IDPATTERNURL=?)
13:20:56,877 DEBUG [org.jboss.as.cmp.jdbc.JDBCLoadEntityCommand.ConfigPatternSostituzioneURL] Executing SQL: SELECT urlDaSostituire, protocolloDaSostituire, dominioDaSostituire, numPortaDaSostituire, stessiParametriBD, tipoSostituzioneURL, messaggioPagina, contentType, sostituisciRifAssoluti, PATTERNURL_IDPATTERNURL FROM CONFIGPATTERNSOSTITUZIONEURL WHERE (patternurl_idPatternURL=?)
13:20:57,264 DEBUG [org.jboss.as.cmp.jdbc.JDBCLoadEntityCommand.ConfigPatternSostituzioneURL] Executing SQL: SELECT urlDaSostituire, protocolloDaSostituire, dominioDaSostituire, numPortaDaSostituire, stessiParametriBD, tipoSostituzioneURL, messaggioPagina, contentType, sostituisciRifAssoluti, PATTERNURL_IDPATTERNURL FROM CONFIGPATTERNSOSTITUZIONEURL WHERE (patternurl_idPatternURL=?)
13:21:03,920 DEBUG [org.jboss.as.cmp.jdbc.JDBCLoadEntityCommand.ConfigPatternSostituzioneURL] Executing SQL: SELECT urlDaSostituire, protocolloDaSostituire, dominioDaSostituire, numPortaDaSostituire, stessiParametriBD, tipoSostituzioneURL, messaggioPagina, contentType, sostituisciRifAssoluti, PATTERNURL_IDPATTERNURL FROM CONFIGPATTERNSOSTITUZIONEURL WHERE (patternurl_idPatternURL=?)
... and so on
Every call to a getter on the ejb PatternURL result in a separate SQL query!! This affect performance and I need to optimize this behaviour. Please help me.
Cheers
Verny