File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Simple(?) JMX Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Simple(?) JMX Question" Watch "Simple(?) JMX Question" New topic

Simple(?) JMX Question

Saul Tocsin

Joined: Feb 25, 2012
Posts: 14
Hi All,

I wasn't quite sure in which forum to post something related to JMX. A search revealed a few JMX posts in this forum....

I have a relatively simple Java class that I start on Node2 as follows:

java -Djava.rmi.server.hostname=Node2 -jar amqpConsumer.jar

When this class starts, it obtains and displays its thread ID. The threadID value displayed is "1". The thread then blocks, waiting for messages to be sent by an AMQP producer.

While the thread on Node2 is waiting, I fire up on Node1 a JMX client that I copied from a very helpful example I found on the Web. The core of this JMX client code looks like this:

Pretty much everything seems to work: the client on Node1 connects to the agent on Node2 and displays threadID, thread name, and thread state for each thread:

45:JMX server connection timeout 45 / TIMED_WAITING
44:RMI TCP Connection(41)- / RUNNABLE
43:RMI TCP Connection(40)- / RUNNABLE
18:RMI Scheduler(0) / TIMED_WAITING
16: DestroyJavaVM / RUNNABLE
15:AMQP Connection / RUNNABLE
14:SimpleAsyncTaskExecutor-1 / TIMED_WAITING
13:AMQP Connection / RUNNABLE
12:RMI TCP Accept-0 / RUNNABLE
11:RMI TCP Accept-9999 / RUNNABLE
10:RMI TCP Accept-0 / RUNNABLE
5:Attach Listener / RUNNABLE
4:Signal Dispatcher / RUNNABLE
3:Finalizer / WAITING
2:Reference Handler / WAITING

But notice that there is no threadID 1.

Perhaps incorrectly, I have assumed that in talking to the JVM's JMX agent, I should be able to enumerate all of the threads known to that JVM. So I am presently baffled as to why I don't see my thread returned by

Is there some way in which I must instrument my class so that it becomes visible to the JVM's JMX agent?

Thank you for your help.

Saul Tocsin

Joined: Feb 25, 2012
Posts: 14
All, turns out this was a dumb mistake on my part.

Thread ID 1 terminated and that's why it's no longer visible. I incorrectly thought that it was blocking when, in fact, it started up a listener as a distinct thread and then terminated.

I agree. Here's the link:
subject: Simple(?) JMX Question
It's not a secret anymore!