Flylib.com

Books Software

 
 
 

Examining the Server (JMX ConsoleJMX Console


Examining the Server (JMX ConsoleJMX Console

The JBoss application server provides a management application that lets you see and manage the services that are deployed and running inside the server. JBoss itself is implemented as a microkernel composed of managed beans (MBeans). The MBeans that are visible provide you a way to manage the resources and applications that are deployed on your application server. This allows you to monitor and modify applications and their usage. You can see what MBeans you have through the JMX Console. The JMX Console organizes the MBeans by the domain, as well by type (service, database, etc.). When you select an MBean you are taken to a page where you can view and edit attributes or invoke the operations of that MBean.


Note: You can manage all the JBoss services through the JMX Console. If you provide MBeans for your own services, you will see them here too.

How do I do that?

You can get to the JBoss JMX Console by going to the main web page (http://localhost:8080) and choosing the JMX Console link. This will take you to the jmx-console web application at http://localhost:8080/jmx-console. When you're there, you'll see something like Figure 1-2.

Developer's Notebook 1-2. JMX Console

JBoss provides an MBean that allows you to look at your server information. To do that now, scroll down in your browser until you get to the section for the jboss.system domain. You should see a link for this: type=ServerInfo . Choose that link and you'll see the ServerInfo MBean page. It will look something like Figure 1-3.

Developer's Notebook 1-3. JMX Console view of ServerInfo

You can see what JVM JBoss is running on top of, what operating system it is running on, etc. That's useful information, especially if you are doing remote monitoring.


Note: If you are feeling adventurous, look at some of the other MBeans and see what other types of information are exposed.

What just happened ?

You opened the JMX Console on the JBoss server and viewed the ServerInfo MBean. You also saw that the MBeans are organized according to the domain they are in. While this might not seem like much now, it will come in handy as we work our way through the book.


Shutting Down the Server

Now that you know how to start the server and look at it using the JMX Console, you need to know how to shut it down properly. It's really pretty simple, so let's get to it.

How do I do that?

You can shut down the server in three ways:

  • Use the JMX Console to go to the jboss.system domain and choose the type=Server MBean link. On the MBean page, scroll down to the operations section and click the "Invoke" button for the shutdown( ) operation.

  • Run the shutdown script for your platform in the same directory where you found the run script.

  • Type Ctrl-c in the same console window where you started JBoss.

When JBoss is stopped , you'll see the following message:

03:50:02,412 INFO  [Server] Shutdown complete

You can verify that JBoss has stopped by trying to access the server in your web browser. You won't be able to connect because the server is not running anymore.

What just happened ?

Just as you would expect, the application server shut down. You also learned three different ways to stop JBoss, and you got to see another useful MBean. Of those three ways, when should you use one or the other?


Note: The shutdown script is in the bin directory with the startup script! The twiddle script is a program for "twiddling" with a remote JBoss server.

In development, the Ctrl-c option is the easiest because you will likely have an open terminal window running JBoss. However, if JBoss is running as a service, especially on a remote machine, you'll need to use one of the other options. If you have shell access to the machine, the shutdown script will work fine. You can also use the shutdown command to shut down a remote JBoss instance, but this requires a local JBoss installation and a few extra command-line arguments. For remote machines, it's often more convenient to just use the JMX Console. If you keep a bookmark set to the ServerInfo MBean, it can be a very quick process. In the end, each option serves the needs of different types of users, so just choose whatever is most convenient for you.