Since WebLogic 6.0, Java Management API (JMX) is required for managing WebLogic servers. Through this API, you can search for and manage beans (mbeans) in the application server and query the configuration information and runtime monitoring information through them. In addition, this API can be used to change the server configuration. In fact, this API has been used on the console and other management tools to complete their work and provide report data.
This API is a powerful monitoring tool. Let's look at an example. In this application, there is a majority of static content, some of your personalized JSP pages, a registration system, and a data system based on JMS (Java messaging services, Java Message Service, and a small-payment application system. Where can we use JMX in this application to benefit us? On a static page, you can access information for fileservlet and see how much time it takes to serve static content. The time may be less than you expected, because the browser automatically caches part of the content on the client. Most requests for static content are head requests to check for changes. For dynamic pages, each servlet in the system is calculated separately. This data does not reflect the user's experience (because there is a delay between the user's request sending and the response to the page ), however, the data tells the average time each servlet spends on one request and how many requests are completed. Our registration system is an entity bean, while the payment system is a stateless Session Bean returned by external services. Both beans can be monitored, and these monitoring information can help us optimize the cache and pool size. Our data can also help determine whether we have obtained the required information or how many users are using the data. Throughput can also be calculated using the attributes of JMS topic and queue mbean. In addition, all JDBC connections can be monitored, and from their mbeans, you can find the number of connection pools to be used. For example, this will help you determine whether more database client authorization is required.
The second purpose of mbeans on the WebLogic Server is to configure information. By configuring mbeans, all resource configurations are included in the runtime. These mbeans are essentially the representation of information contained in the config. xml file. All content of the application deployed on the server listening port is included in these interfaces. Most of the individual attributes are directly related. However, attribute sets describing a deployment unit are complex and are collected in the weblogic. deployer class for convenience. Direct access to them is possible, but operations other than viewing the configuration and not changing it are not recommended. Other attributes are random, but be careful. However, if a component (such as a JDBC pool) is redeployed or the server is restarted, most of these attributes actually only change the running behavior. The scope of these configuration-oriented mbeans applications ranges from deciding to use resources for a specific application to adjusting the value based on the feedback from mbeans.
As you can see, there is a lot of information-but if you are not familiar with JMS and WebLogic servers, how do you get started? It is actually not that difficult. As long as you can use JNDI and read javadocs, you will find it quite easy to manipulate mbeans. In the following sample code, we will show you how to obtain the mbean home interface and JDBC pool of the local server.
Mbeanhome home = (mbeanhome) New
Initialcontext (). Lookup (mbeanhome. local_jndi_name );
Set pools = home. getmbeansbytype ("jdbcconnectionpool ");
The above Code provides mbean configuration for the JDBC (Java database connectivity, Java database connection) pool. If you want to monitor the connection pool without considering their configurations, you only need to add "RunTime" to change the mbean type. From this mbean, you can determine important information, such as whether there is a connection leak-you can even get a stack trace to find the specific location of the connection.
What if you don't want to do any Java programming, just like using the JMX mbean system from a script file? Fortunately we have a command line tool that allows you to directly view and change the mbean-weblogic.Admin in the form of command lines. In addition to the pinging server, which obtains the JNDI list, resets the connection pool, and closes the server, it provides a layered structure for direct access to mbean. In the following code example, you will see such a weblogic. admin command.
Java weblogic. Admin-username system-Password [Password]-URL [url] Get
-Pretty-type jdbcconnectionpool
This Code provides a simple and easy-to-read description of mbeans, compared to the type descriptor that adds properties to these mbeans. Similarly, a set command will change the attributes of any mbean in the system.
With this tool, you should be able to monitor your applications within Java and outside the script.