Tuesday, 21 November 2017

IBM Java and Health Centrer - There's More

Following an earlier post: -

I've been guiding a colleague in the use of HC, outside of WebSphere Application Server (WAS).

This time I wanted to show how HC could be used to monitor a Plain Ole Java Object (POJO), specifically a Java class.

Here's one I prepared earlier: -


public class HelloWorld
public static void main(String[] args)
while (true)
System.out.println("Hello, World");

WARNING - this will run forever, in an infinite loop, but it's good for my testing purposes.

Having setup my shell to reflect the IBM Java 8 JRE, thanks to the WAS setupCmdLine.sh script: -

source /opt/ibm/WebSphereProfiles/Dmgr01/bin/setupCmdLine.sh 

I compiled the class: -

javac HelloWorld.java 

and executed it: -

java HelloWorld

to prove that it works.

I then added HC into the mix: -

java -Xhealthcenter:transport=jrmp HelloWorld

Note that, as before, I've added :transport=jrmp into the mix, as I'm using Eclipse on macOS with Oracle's Java 8 JRE on the client-side, even though the server-side is using the IBM Java8 JRE.

I was then able to hook up Eclipse, as per the previous blog post.

One other useful tip; if I start the Java class thus: -

java -Xhealthcenter:transport=jrmp HelloWorld >> /tmp/foobar

the actual "Hello World!" message gets appended to /tmp/foobar but I see: -

in the console, allowing me to validate that HC is running and listening on port 1972.

I also validated this from another terminal: -

where 49134 is the Process ID of the running JRE: -

and then probed it: -

and: -

Job done !

No comments:

Setting Authorization Headers in IBM API Connect Test and Monitor

I've recently started exploring the IBM API Connect Test and Monitor  tool on IBM Cloud here: - https://www.ibm.com/cloud/api-connect/...