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.
I am trying to write into the database many records (say >1000) using entity beans. The problem is when the user hits the submit button for this processing, he has to wait for a long time till the long process completes and is forwarded to the next page on success. Sometimes, the user may think that the page is doing nothing and hit the submit button twice due to the delay.
Is there a way, that I cud put this process (writing 1000 records) in a queue and return to the next page so the user sees the next page soon and the writing to database takes place in the back?
Given that you posted this in the EJB forum, presumably these database interactions are somehow implemented in EJB, e.g. entity beans. If so, another thing to take a look at are the vendor-specific deployment descriptor options that control how your database changes are actually processed during and at the end of the transaction. Sometimes you can get a very significant speedup by ensuring that all the writes happen just on the transaction commit. Particularly in WebLogic and I believe also in the most recent JBoss 3.2.x and 4.0.x releases, you can see very big differences in CMP performance because the container can sometimes switch to using SQL batching.
The JMS approach works ok too, but only if you aren't expecting to forward the user to a page that reflects the committed results. Obviously those won't always be available if the changes are off processing in some other thread of execution.