My application consists of a suite of web services running in JBOSS 5.1 (Java 6, Spring 3.1). The web service code calls a DAO function to update the DB and, for performance reasons, I’d like to make that call asynchronous (the update is not important to the web service response). What are my options here?
The consensus seems to be to avoid managing threads myself and let the app server do it. What are my options in JBOSS 5.1 (Java 6, Spring 3.1)? Some kind of JMS solution? Or using JBOSS ThreadPool? Or MDBs?
JMS (MDB being the easiest way to do it) certainly works and I would recommend doing that when you’re using a Java EE platform below Java EE 6, especially because you immediately have queuing support to be able to throttle execution should that be neccessary. Plus JMS keeps working no matter which version of Java EE you target.
I’ve also abused the EJB timer service for asynchronous invocation of an EJB method, but that is very ugly.