Hi

to do so simply inject the sessioncontext get the business facade (on
yourself) to invoke the @Async method.

PostContruct are not async by default AFAIK

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/10/23 zmirc <[email protected]>

> 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.
>

Reply via email to