I'm trying to use some kind of container managed thread service. Basically I want to submit a task that should be run as a separate thread. Inside this runnable task, I need to call some EJB methods that internally are using transactions.
So how to get handle to Jboss managed ExecutorService or Executor? Once i get handle to this service, i can run tasks easily.
threads subsystem can be defined in standalone.xml or domain.xml. There are good links on that. But I tried searching for atleast an hour and couldn't find any useful article on how to get handle to this thread service and submit runnable tasks. Any way I can inject or do JNDI lookup on this service?
The only other way that I know of is to use a javax.resource.spi.work.WorkManager. But I think you need to write a resource adapter to make use of that (I may be wrong).
Generally speaking, @Asynchronous exists exactly so that you don't have to worry about thread pools at a code level. It *is* the implementation of the "container managed thread service" that you're looking for.
The EJB spec has pretty much always stated
The enterprise bean must not attempt to manage threads.
Stephen is right. Java EE provides mechanisms for running code in other threads (e.g. javax.ejb.Asynchronous, JMS, javax.resource.spi.work.WorkManager (but this is only for JCA resource adapters)). Using some other mechanism would be non-portable and not recommended. Furthermore, while the threads subsystem exists today it is deprecated so it will disappear in the future.