Walter Andresen wrote:I need to implement asynchronous processing in the web application. When a user logs in, I need to do some time consuming actions, sync it with another system, save some audit
info, etc, etc.
What I can do is to create a separate thread and execute some code, without waiting for a response. Or I can also use JMS.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Stephan van Hulst wrote:Winston, I strongly disagree.
You should always try to avoid spawning threads...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Stephan van Hulst wrote:What's important is that your application doesn't handle the creation of such threads if it runs inside an application container, because bad thread management may cause an application to start thrashing. This includes using executor services, because you're bypassing the container's own thread pool.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Stephan van Hulst wrote:Threads are resources, you should handle them the same way you handle database connections.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |