This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
We have a simple jsp/struts UI.
Using the UI we can start a batch process by clicking on Run button.
The batch process would fetch records from DB and write to MQ.
We have a threshold value of 30000 records.
When the program retrieves 30000 records we spawn a new thread and pass that list of 30000 records to that thread which does
writing to MQ and the retrieval continues. This process repeats everytime counter reaches 30000 mark.
Now on the UI we are going to have Stop button. When user clicks on stop button the execution of that batch should be stopped. (All the threads that might have spawned should be stopped on clicking of stop).
We have layered architecture with UI (jsp and forms / actions (struts)) and jdbc framework in separate packages.
Have you thought of using threadpools for your work? Using them you do not have to take the overhead of creating a new thread and you also get cancel(shutdown) functionality for free!
With jdk5 threadpools come along with the jdk. For version before that you can use the backport of the same.