3 Replies Latest reply on May 22, 2009 8:36 PM by vk101

    Is daemon-like process possible from app startup?

      I know that asynchronous methods and timed methods are possible in Seam, but I'm wondering if that also provides for the ability to have some kind of daemon-like process to run starting from the time the application starts up?


      I get the impression that asynchronous methods are more used to execute something 'behind-the-scenes' in response to something a user directly or indirectly kicks off the first time. But how about something to poll for something in the database and run some other work in a different application, on a continual basis for the lifetime of the application, regardless of whether a user kicks it off or not?

        • 1. Re: Is daemon-like process possible from app startup?
          swd847

          Create an application scoped component marked @Startup the either executes and @Asynchronous method or spawns a thread directly.

          • 2. Re: Is daemon-like process possible from app startup?

            Thanks, I'll give that a go! So if I have an application-scoped component that executes an @Asynchronous method of a ScopeType.STATELESS component (ComponentA), how can ComponentA make available something in a context to another component (ComponentB) that it calls.


            For example, if ComponentB needs certain objects available in context variables, how can a STATELESS ComponentA, which calls ComponentB, set up the context variables correctly? I'm under the impression that if ComponentA STATELESS it can't outject something to any of the stateful contexts.

            • 3. Re: Is daemon-like process possible from app startup?

              Are @Asynchronous methods run asynchronously but not in parallel? If I've got a method scheduled to run every 30 seconds, and I set a breakpoint in my debugger, the next execution of the asynchronous method doesn't start until after the first execution of my method is over.


              Shouldn't new threads be created every 30 seconds running the same method, meaning that if the method takes longer than 30 seconds to execute, multiple threads should be running the same method at one time?