JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle GlassFish Server Message Queue 4.5 Developer's Guide for Java Clients
search filter icon
search icon

Document Information

Preface

1.  Overview

2.  Using the Java API

3.  Message Queue Clients: Design and Features

4.  Using the Metrics Monitoring API

Monitoring Overview

Administrative Tasks

Implementation Summary

To Implement Message-Based Monitoring

Creating a Metrics-Monitoring Client

To Monitor Broker Metrics

Format of Metrics Messages

Broker Metrics

JVM Metrics

Destination-List Metrics

Destination Metrics

Metrics Monitoring Client Code Examples

A Broker Metrics Example

A Destination List Metrics Example

A Destination Metrics Example

5.  Working with SOAP Messages

6.  Embedding a Message Queue Broker in a Java Client

A.  Warning Messages and Client Error Codes

Index

Creating a Metrics-Monitoring Client

You create a metrics monitoring client in the same way that you would write any JMS client, except that the client must subscribe to one or more special metrics message topic and must be ready to receive and process messages of a specific type and format.

No hierarchical naming scheme is implied in the metrics-message names. You can’t use a wildcard character (*) to identify multiple destination names.

A client that monitors broker metrics must perform the following basic tasks:

To Monitor Broker Metrics

  1. Create a TopicConnectionFactory object.
  2. Create a TopicConnection to the Message Queue service.
  3. Create a TopicSession.
  4. Create a metrics Topic destination object.
  5. Create a TopicSubscriber.
  6. Register as an asynchronous listener to the topic, or invoke the synchronous receive() method to wait for incoming metrics messages.
  7. Process metrics messages that are received.

    In general, you would use JNDI lookups of administered objects to make your client code provider-independent. However, the metrics-message production is specific to Message Queue, there is no compelling reason to use JNDI lookups. You can simply instantiate these administered objects directly in your client code. This is especially true for a metrics destination for which an administrator would not normally create an administered object.

    Notice that the code examples in this chapter instantiate all the relevant administered objects directly.

    You can use the following code to extract the type ( String) or timestamp (long) properties in the message header from the message:

    MapMessage mapMsg;
    /*
    * mapMsg is the metrics message received
    */
    String type = mapMsg.getStringProperty("type");
    long timestamp = mapMsg.getLongProperty("timestamp");

    You use the appropriate get method in the class javax.jms.MapMessage to extract the name-value pairs. The get method you use depends on the value type. Three examples follow:

    long value1 = mapMsg.getLong("numMsgsIn");
    long value2 = mapMsg.getLong("numMsgsOut");
    int value3 = mapMsg.getInt("diskUtilizationRatio");