File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Servlet to monitor other application over JMX. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Servlet to monitor other application over JMX." Watch "Servlet to monitor other application over JMX." New topic

Servlet to monitor other application over JMX.

raja patil

Joined: May 26, 2008
Posts: 24

I am absolute beginner of JMX. We have deployed Symmetric DS replicator at Branch Offices in a local Tomcat Instance and
we can access Mbeans for its Instance to get various values successfully Over JMX with VisualVM/Jconsole etc. etc.
The replicator is replicating Local Database to HO which is Updated by Bunch of Local Applications written in non Java
languages like (VB/Delphi/C++ quite heterogeneous mix of small applications). We plan to extend these applications to
have replication Information dashboard so that users will info about status of replication activity. The information
we would like to show is accessible in Jconsole through Mbeans for Symmetric DS instance.

The idea we would like to implement is to have our own servlet deployed along with symmetric DS in same Tomcat Instance
as Another Context. Local application will pass HTTP Request to this servlet and servlet will respond with information (in XML Format)
about status of replication by querying over JMX to symmetric DS.

Is it possible to connect another context over JMX in same Tomcat Instance ?

if yes, How to do that ? any example/URLs/Books/code snippets etc. etc. are highly appreciated.

Thanks and warm regards.

Raja Patil.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Well, without doing anything as ambitious as RTFMing, thus putting you at the mercy of my questionable memory, I believe that JMX runs over a selected network port. So each monitored JVM needs its own unique port, since each JVM is an independent OS process and processes cannot share a port.

Servlets are not an ideal monitoring system, however, since they are expressly forbidden from spawning their own threads and servlets only run when a client request has been received and a response needs to be generated. So unless you're looking for a URL that a third party can use to query the various JMX sources on-demand, a servlet is not what you should use. For continuous or periodic monitoring, spawn a thread from the ServletContextListener.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Servlet to monitor other application over JMX.
It's not a secret anymore!