Jolokia Java Client

I am new to JMX. I have developed a web service using Glassfish as a server. Now I want to control my application,

My first thought was to use Jconsole and JVM as a monitoring tool. After continuing my research, I find these articles:

http://www.javacodegeeks.com/2012/02/client-side-server-monitoring-with.html

Accessing JMX via HTTP Alternatives

This suggests that I have to use a bridge like Jolokia, which I obviously don't understand the reason. JConsole + mbeans is not enough?

I continue my research and I created a java project using their example:

  public static void main(String[] args) throws MalformedObjectNameException, J4pException {
        J4pClient j4pClient = new J4pClient("http://localhost:8080/jolokia/");
        J4pReadRequest req = new J4pReadRequest("java.lang:type=Memory",
                "HeapMemoryUsage");
        J4pReadResponse resp = j4pClient.execute(req);
        Map<String, String> vals = resp.getValue();
        System.out.println("Memory usage: used: " + vals);

    }

      

It worked, I get a message related to my usage memory. But, I don't know what it was.

What's the best way to monitor my web service?

+3


source to share


1 answer


I recommend using JVisualVM. It is very easy to use and provides excellent information. Just start the application and start JVisualVM and it will detect the java application running. You can click on it to get all kinds of information in graphical form. Use it for memory monitoring, threads, garbage collection, and heap dumps.

The tool you mentioned Jolokia provides a way to monitor the app with a lower impact, but it seems like you will need to do more coding. JVisualVM provides a lot of information out of the box.



You may need to evaluate the performance impact of JVisualVM, but I wouldn't worry about that at first if your site is not fast. You can also choose what to monitor for a lower impact.

+4


source







All Articles