aspose file tools*
The moose likes Websphere and the fly likes Design/Architecture Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Design/Architecture Question" Watch "Design/Architecture Question" New topic
Author

Design/Architecture Question

Bob Hager
Greenhorn

Joined: Oct 23, 2008
Posts: 15
Hello,

I have a design / architecture question that I'd appreciate some help with.

I am working on a web application that uses Websphere app server. But have a requirement to check a certain DB table periodically (every 2 minutes), and if new rows were inserted, then do something accordingly (namely: call a web service).

The obvious approach is to have this code launched in its own JVM - as a standalone application. But I feel this is not optimal because that JVM will have to be manually managed: For example, if it throws an exception for instance, the JVM will exit and it will have to be manually restarted - among other things..

At the same time, I don't believe standard JEE managed components (Servlets and EJBs) can help me for this purpose, because they run as services that have to be invoked by someone/something. While what I'm trying to do is more of a maintenance/daemon functionality that has to run independently in the background.

So, do you think this approach is sound? and do you know of other - better - alternatives, especially in a Websphere environment?

Much appreciated!

Bob
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Bob,
You could use WebSphere scheduler. Or if you are on a recent version you could use a TimerTask (not IBM specific.) I recommend the later since you don't require complex scheduling.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bob Hager
Greenhorn

Joined: Oct 23, 2008
Posts: 15
Jeanne Boyarsky wrote:Bob,
You could use WebSphere scheduler. Or if you are on a recent version you could use a TimerTask (not IBM specific.) I recommend the later since you don't require complex scheduling.





Jeanne,

Thanks for your informative response. I looked into the WebSphere scheduler, and I saw that it requires the WAS admins to write some scripts to schedule the job. That's unfortunate because our Admins that I work with are both overly protective of their territory as well as incompetent (or at very least: lazy), so I don't see them finishing that anytime soon

The other alternative, using JDK's TimerTask leaves me with the original problem of how to initialize/launch that service. I'd like to avoid running it in a stand-alone mode if possible.

I found a third way that I plan to investigate, using Quartz (open source Apache license 2.0). It sounds simple to use and robust, and can be instantiated from an initialization servlet as suggested by this article:
http://www.theserverside.com/tt/blogs/showblog.tss?id=QuartzSchedulerInJ2EE

Thanks

Bob

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Bob Hager wrote:The other alternative, using JDK's TimerTask leaves me with the original problem of how to initialize/launch that service. I'd like to avoid running it in a stand-alone mode if possible.

I found a third way that I plan to investigate, using Quartz (open source Apache license 2.0). It sounds simple to use and robust, and can be instantiated from an initialization servlet as suggested by this article:
http://www.theserverside.com/tt/blogs/showblog.tss?id=QuartzSchedulerInJ2EE

Why can't you initialize/launch the TimerTask from the servlet (as you are thinking to do with Quartz) ? You can set your web.xml to load the servlet on startup so that happens automatically.

Bob Hager
Greenhorn

Joined: Oct 23, 2008
Posts: 15
Jeanne Boyarsky wrote:
Bob Hager wrote:The other alternative, using JDK's TimerTask leaves me with the original problem of how to initialize/launch that service. I'd like to avoid running it in a stand-alone mode if possible.

I found a third way that I plan to investigate, using Quartz (open source Apache license 2.0). It sounds simple to use and robust, and can be instantiated from an initialization servlet as suggested by this article:
http://www.theserverside.com/tt/blogs/showblog.tss?id=QuartzSchedulerInJ2EE

Why can't you initialize/launch the TimerTask from the servlet (as you are thinking to do with Quartz) ? You can set your web.xml to load the servlet on startup so that happens automatically.



You're right! I'll do exactly that.

Thanks..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

Actually, the current way to start something up when the web application starts and terminate it when the web application stops is to use a ServletContextListener. Use its contextInitialized and contextDestroyed methods.

Using a servlet to do this is okay, but architecturally it hijacks the purpose of the servlet (which is to produce a response to an HTTP request).
Saqib Siddiqui
Greenhorn

Joined: Jun 23, 2005
Posts: 1
Bob, best way is to use Quartz API. Vist this link http://www.opensymphony.com/quartz/wikidocs/TutorialLesson1.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design/Architecture Question
 
Similar Threads
Can I use local interface?
WebSphere 4.0.5 - Cluster Version - Running as a Service
Web App Architecture
outsourcing development of a J2EE web application
Clustering in WAS