Monitoring JMS resources with JBoss AS 7

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

In this 5 minutes tutorial we will show how to monitor the critical metrics of JMS subsystem of standalone and domain JBoss AS 7 servers.

Well, at first start JBoss AS 7 using a distribution that ships with the messaging subsystem (e.g.):


standalone.sh -c standalone-full.xml

The JMS metrics can be both inspected using CLI and the Web admin interface.

Using the CLI

If you want to monitor a JMS destination using the CLI, you can use the read-resource command on the selected destination (for example the testQueue)


/subsystem=messaging/hornetq-server=default/jms-queue=testQueue/:read-resource(recursive=false,proxies=false,include-runtime=true,include-defaults=true)
{
    "outcome" = "success",
    "result" = {
        "consumer-count" = 0,
        "dead-letter-address" = "jms.queue.DLQ",
        "delivering-count" = 0,
        "durable" = true,
        "entries" = [
            "queue/test",
            "java:jboss/exported/jms/queue/test"
        ],
        "expiry-address" = "jms.queue.ExpiryQueue",
        "message-count" = 2L,
        "messages-added" = 2L,
        "paused" = false,
        "queue-address" = "jms.queue.testQueue",
        "scheduled-count" = 0L,
        "selector" = undefined,
        "temporary" = false
    }
}

And this is a list ofthe key metrics:

message-count:       The number of messages currently in this queue.
delivering-count:     The number of messages that this queue is currently delivering to its consumers.
scheduled-count:     The number of scheduled messages in this queue.
messages-added:     The number of messages added to this queue since it was created.

If you are running in domain mode, you have to specify the host and server before the subsystem:


/host=master/server=server-one/subsystem=messaging/hornetq-server=default/jms-queue=testQueue/:read-resource(recursive=false,proxies=false,include-runtime=true,include-defaults=true)

  Handy Trick: how to read a metric using the Bash shell

If you are running a linux shell (or en emulator for Windows) you can take advantage of non-interactive features of CLI to read a single attribute which can be stored into a shell variable. Create a file named for example metric.cli which contains the connect command and a read-attribute of a metric (e.g. the consumer-count)


connect 127.0.0.1
/subsystem=messaging/hornetq-server=default/jms-queue=ExampleQueue/:read-attribute(name=consumer-count,include-defaults=true)

Now execute this cli in non-interactive mode, capturing with awk the result:

consumers=$(jboss-cli.sh –-file=metric.cli | awk '$1=="\"result\"" {print $3}')

if you try to echo the consumers variable, it will contain the number of consumers for a JMS Destinations


$ echo "$consumers"

15

Using the Web admin console

You can use as well the Web admin console which exposes the same metrics by navigating into the Runtime upper tab and selecting the JMS Destinations in the left panel:

jboss as 7 destinations jms jms

Related articles available on mastertheboss.com

How to configure a Queue in JBoss ?

This article has been moved here: JBoss JMS configuration

How to create a Queue with Jmx Console ?

  Bring up the JMX Console in your browser and look for the sect

JBoss JMS Queue example

The following article shows how to create a simple JMS Queue Prod

JBoss JMS Topic example

The following article shows how to create a simple JMS Topic Publ

JBoss HornetQ simple tutorial

HornetQ is an open source project to build a multi-protocol, embe

How do I configure a Queue/Topic to work in a cluster?

  JBoss AS 5 Just set the Clustered attribute to "true" in your

Follow us on Twitter