Hi!
Shouldn't async methods not block even if they are called in @PostConstruct?
Here is the sample code, which blocks if ran in Tomee 1.6.0 2013.10.23 / 05
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.ejb.Asynchronous;
import javax.ejb.Singleton;
import javax.ejb.Startup;
@Singleton
@Startup
@Asynchronous
public class Async {
@PostConstruct
private void init() {
// pretending to initialize, then to call one of the methods
doingHardWork();
}
public void doingHardWork() {
System.out.println("Working hard START");
try {
Thread.sleep(1000 * 10);
} catch (InterruptedException ex) {
Logger.getLogger(Async.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Working hard END");
}
}
--
View this message in context:
http://openejb.979440.n4.nabble.com/Async-call-blocks-in-PostConstruct-tp4665703.html
Sent from the OpenEJB User mailing list archive at Nabble.com.