maverik87 [
https://community.jboss.org/people/maverik87] created the discussion
"EJB asynchronous method"
To view the discussion, visit:
https://community.jboss.org/message/748868#748868
--------------------------------------------------------------
I'm using JBoss 7.1.1 final. I have a stateful EJB with an asynchronous method. From a
jsp I call a synchronous method of the previous EJB and this method call the asynchronous
one of the same EJB via proxy.
@Stateful
@Remote(IExcursionDAOWithPrefetch.class)
public class ExcursionDAOWithPrefetch implements IExcursionDAOWithPrefetch {
@Resource SessionContext ctx;
@EJB(lookup=...) IExcursionDAO excursionDAO;
...
public Excursion findExcursionById(int id, boolean loadCoordinates) {
// Retrieve from cache
Excursion excursion = cache.getExcursionById(id);
if(excursion == null) {
// Retrieve from database
excursion = excursionDAO.findExcursionById(id, loadCoordinates);
logger.info("excursion not in cache");
}
else {
logger.info("excursion in cache");
}
ctx.getBusinessObject(IExcursionDAOWithPrefetch.class).loadCache(excursion);
return excursion;
}
@Asynchronous
public void loadCache(Excursion excursion) {
if(excursion != null) {
cache.invalidateCache();
cache.addExcursion(excursion);
List<Excursion> closeExcursions =
excursionDAO.findCloseExcursions(excursion, 10);
if(closeExcursions != null) {
for(Excursion exc : closeExcursions) {
cache.addExcursion(exc);
}
}
}
}
}
loadCache() method is executed asynchronously but the jsp awaits its end even though it
calls findExcursionById() method (and not loadCache()).
Can someone help me?
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/748868#748868]
Start a new discussion in EJB3 Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]