Update 6/27/2011: Tom Barnes indicated a clarification, check out the comments.
Ever want to know who was connected to your WebLogic Server instance for troubleshooting? An email exchange about this topic and JMS came up this week, and I’ve heard it come up once or twice before too. Sometimes it’s interesting or helpful to know the list of JMS clients (IP Addresses, JMS Destinations, message counts) that are connected to a particular JMS server. This can be helpful for troubleshooting. Tom Barnes from the WebLogic Server JMS team provided some helpful advice:
The JMS connection runtime mbean has “getHostAddress”, which returns the host address of the connecting client JVM as a string.
A connection runtime can contain session runtimes, which in turn can contain consumer runtimes. The consumer runtime, in turn has a “getDestinationName” and “getMemberDestinationName”. I think that this means you could write a WLST script, for example, to dump all consumers, their destinations, plus their parent session’s parent connection’s host addresses.
Note that the client runtime mbeans (connection, session, and consumer) won’t necessarily be hosted on the same JVM as a destination that’s in the same cluster (client messages route from their connection host to their ultimate destination in the same cluster).
Writing the ScriptSo armed with this information, I decided to take the challenge and see if I could write a WLST script to do this. It’s always helpful to have the WebLogic Server MBean Reference handy for activities like this. This one is focused on JMS Consumers and I only took a subset of the information available, but it could be modified easily to do Producers. I haven’t tried this on a more complex environment, but it works in my simple sandbox case, so it should give you the general idea.
Example OutputI expect the output to look something like this and loop through all the connections, this is just the first one:
1 JMS Connections found for AdminServer with JMSServers myJMSServer
Host Address = 127.0.0.1
ClientID = None
Sessions Current = 16
Name = consumer40
Messages Received = 1
Member Destination Name = myJMSModule!myQueue
Notice that it has the IP Address of the client. There are 16 Sessions open because I’m using an MDB, which defaults to 16 connections, so this matches what I expect. Let’s see what the full output actually looks like:
Thanks to Tom Barnes for the hints and the inspiration to write this up.
Image of telephone switchboard courtesy of http://www.JoeTourist.net/ JoeTourist InfoSystems