2 Replies Latest reply on Jan 22, 2013 11:00 AM by sandeepj

    @Asynchronous methods in JBoss 6.1.0 Final




        I am deploying an EAR and at startup I want some piece of code to run asynchronously and NOT block the server startup.

         In my MBean, I am using the @Aynchronous tag on the method that should be run asynchronously. But I don't see that happening.

        The server waits for this method to finish before it starts up.


        The workaround that I am using for now is creating a new thread inside this method.


        Please have a look at the sample code and let me know, if I can do any better.

         Any help is greatly appreciated !




      @Service(objectName = "sampleJMX:service=myService")


      public class StartUpServiceMBean implements StartUpService {


          // --- I Need to run this method asynchronously . But @Aynchronous tag on this method is NOT helping achieve that.

          public void start() {


                // ---- WorkAround: Create a new thread and let it do the job independently

               new Thread(new Runnable() {

                  public void run() {

                          // Run my indexing