Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Best JEE Approach For Long Running Task  RSS feed

 
Bill Compton
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a task that may run for as little as 2 minutes or as long as 2 days. It will spawn a series of child processes that do most of the work, waiting for each child to finish before starting the next. While it is running, we need to be able to report status (either polling or monitoring a JMS topic is fine) and the user needs to be able to stop it before it finishes. We may want to run this under an app server (probably WebLogic).

What's the best approach for this? MDBs and session beans both seem like they are not the best for this. For background, here are some related topics from this forum:
This topic says there is no built-in solution, which could imply that we should just create a custom class that starts a new Thread. This topic indicates that a session bean with a transaction attribute of NotSupported would be good.

Suggestions? Thanks in advance.

-Bill
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can avoid creating your own threads by using Java 5 thread pool.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well this may seem bold, but the "Long Running Process" post talks about a ClassCastException, iow does not really do much for the topic of this post. When I sat down to write my primary application, a threading approach evolved even with limited coding and logic skills. Though given brief but real testing, it's performance was clearly acceptable and I would wonder about any aleady-written code as I have had a clear pattern emerge of having such code run great for a while, then one is forced to 'download the latest software' - which in short means a lot to a great many folks.

The overall design pattern is extremely simple:

  • 1. Make all vars volatile, whether anyone likes it or not.
  • 2. If you have to synch() on more than one object, re-design from top down.
  • 3. Entry is by synchronized, static -> usually called a static factory method.
  • 4. Communication by shared vars, which must be objs.
  • 5. Lots of test first development, followed by heavy loading in alpha.
  • 6. Extreme Programming has several tools to offer.
  • 7. The raw power of the platform has to be taken into design eval.
  • 8. You have to monitor the total thread count somehow.


  • [ December 08, 2007: Message edited by: Nicholas Jordan ]
     
    Rejeev Divakaran
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I would suggest to use WebLogic timer. You can schedule the timers in startup class and cancel the same in shutdown class. Status communication and pause/stop communications can be through a JMS queue.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!