Hi there,
I need to implement a service that reads tasks (descriptions) from the database, does some tasks and sleeps again. The thread must be able to woke up if an other service demands just in time processing. Requirements: 1. Need a Hibernate Session inside the main loop. 2. Needs to be able to woke up (just use Object.notify and Object.wait). 3. Needs to sleep for a couple of minutes, check db for work and sleep again. 4. On shut down it needs to suspend and decompose gracefully. What is the best way to do so? So first I looked at periodic job etc. Nothing to use. So it ends up doing some kind of a service that spawns a thread and the thread does all the progressing. The thread itself uses a runnable to guard against failures and those failures are logged within each task during which the failure occures. So here comes the big question: What should I do. The naive answer is using a SessionSource and create a session each time the thread's runnable starts the processing. Another idea would be set up the worker part as a service that is created every time and let the IOC do all the session creation and handling. But I fear that this is way more complicated then the SessionSource idea. The decomposition on the teardown of the tapestry application requires to deal with certain kind of listeners. What is the best service to add the listener too? Thanks in advance, Martin (Kersten)