last time I did it it was with a @Singleton @Startup starting an async task in @PostCOnstruct and waiting for shutdown in @PreDestroy.
Little trick: to start an async method from "this" inject SessionContext (sc) and do sc.getBusinessLocal(MyEjb.class).myAsync(); Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com> 2015-04-18 16:59 GMT+02:00 Lars-Fredrik Smedberg <[email protected]>: > Understand that... Unfortunately we are running Java EE6 in production and > cannot pull it in as a third party prod for various reasons > On Apr 18, 2015 4:58 PM, <[email protected]> wrote: > > > I am very happy with jbatch aka batchee. > > > > Skickat från min iPhone > > > > > 18 apr 2015 kl. 16:36 skrev Lars-Fredrik Smedberg <[email protected] > >: > > > > > > Hi > > > > > > I need to run a background task that will poll messages from a > > > BlockingQueue, aggregate data (to some degree) and at regular intervals > > > write the data to a file (append to a file). > > > > > > Each appserver instance will write to its own file so there is no need > to > > > sync within a cluster or similar... > > > > > > I guess I could at startup create my own thread and peek the queue > etc... > > > but if I would keep it more strict Java EE 6 and also need access to > > > @ApplicationScoped beans then I guess I could either use a one-off > > > programmatic EJB timer or calling an @Asynchronous EJB methos > > > (started/called from a @Singleton @Startup... EJB). > > > > > > What is the preferred approach you would use? > > > > > > Regards > > > LF > > >
