This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes spawning a daemon thread on Tomcat startup 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 » Tomcat
Bookmark "spawning a daemon thread on Tomcat startup" Watch "spawning a daemon thread on Tomcat startup" New topic
Author

spawning a daemon thread on Tomcat startup

Ajay Saxena
Ranch Hand

Joined: Nov 13, 2006
Posts: 154
I'm exploring the possibility of spawning a daemon thread, that would act as a heartbeat listener,at the Tomcat server startup.

The tomcat server ,on startup, spawns the following threads,among others.

- the main thread that listens on 8005 and awaits SHUTDOWN requests

- the JIOEndpoint Acceptor thread that listens on 8080 for incoming TCP/IP connections

- A processor thread that listens on 8009 for Apache webserver connections

- Other processor threads

I intend to spawn my heartbeat listener thread from the main thread.

Is there a way to achieve that by supplying my code and patching it up with the tomcat binaries? In other words, is it possible to write some sort of plugin?

Or do I need to build the tomcat code along with the hearbeat listener code?

-thanks a lot for your comments.

[ July 08, 2008: Message edited by: Ajay Saxena ]
[ July 08, 2008: Message edited by: Ajay Saxena ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12678
    
    5
That seems unnecessarily complicated. Why not just start the daemon Thread from - say - a ServletContextListener for an app that gets initialized on server startup?

Bill


Java Resources at www.wbrogden.com
Ajay Saxena
Ranch Hand

Joined: Nov 13, 2006
Posts: 154
Well, that would probably be a cleaner approach. In fact I came across such a suggestion on the web somewhere. But still wanted to explore other alternatives. Looks like it's time I revisited the servlet container features of Tomcat. I was actually viewing Tomcat from a management/monitoring perspective,so didn't quite consider this approach.

-thanks for your time and suggestion!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spawning a daemon thread on Tomcat startup
 
Similar Threads
when a servlet calls EJB methods, is it a remote or a local call?
Caching while data changes on a daily basis
Daemon Threads
Auto-restart a web app on Tomcat for high availability
Unable to stop tomcat server 4.1