8.0 Sending Notifications from MBeans

 


8.1 Overview

8.2 Implementing Notifications

8.3 Notification Types

8.4 Sending Notifications

8.5 Viewing Notifications


 

8.1 Overview

 

Management applications need to react to a state change or to a specific condition when it occurs in an underlying resource. XMOJO JMX implementation supports JMX Notification Model which allows MBeans to broadcast such management events, which are called Notifications. To receive the broadcasted Notifications, management applications and other objects register as listeners with the broadcaster MBean. The MBean notification model of JMX enables a listener to register only once and still receive all different events that may occur in the broadcaster.

The JMX notification model relies on the following components:

Any type of MBean, standard or dynamic, may be a notification broadcaster, a notification listener, or both at the same time. Notification filters are usually implemented as callback methods of the listener itself, but this is not a requirement. A JMX Notification event is generated for all the supported protocols namely SNMP, HTML, HTTP, RMI, CORBA, and TL1.

This may lead to a special case of a Standard MBean, which has an empty management interface: its role as a manageable resource is to be a broadcaster of Notifications. It must be a concrete class with a public constructor, and it must implement an MBean interface, which in this case defines no methods. The only method in its class is those implementing the NotificationBroadcaster interface. This MBean may be registered in a Multi-Protocol agent, and its management interface contains only the list of notifications that it may send.

 

8.2 Implementing Notifications

 

An MBean wanting to emit notifications must implement the NotificationBroadcaster  Interface. This interface may be implemented by any type of MBean.  This interface specifies three methods,  which MBeans acting as notification broadcasters must implement:

Adding Notification Listeners

 

Any notification that is emitted must be received at the other end.  The objects that are configured to receive these notifications are called Listeners. These Listeners must be registered with the Notification broadcaster to receive the notification. A listener is registered when it has been added to the broadcaster’s list of notification recipients.

 

The method addNotificationListener() available in the NotificationBroadcaster Interface is used to add a listener to to the broadcaster’s list of notification recipients. When the broadcaster sends a notification, it will send it to all listeners that are currently registered through this interface.

 

The addNotificationListener() method takes the following parameters:

Notification Listener Interface

 

This interface must be implemented by all objects interested in receiving notifications sent by any broadcaster.  This interface defines a unique callback method, handleNotification(), which will be invoked by a broadcaster MBean when it emits a notification.

 

Besides the Notification object, the listener’s hand-back object is passed as an argument to the 'handleNotification' method. This is a reference to the same object that the listener provided upon registration. It is stored by the broadcaster and returned unchanged with each notification.

 

Because all notifications are characterized by their type string, notification listeners implement only one handler method for receiving all notifications from all potential broadcasters. This method should then rely on the type string, other fields of the notification object, and on the hand-back object to determine the broadcaster and the meaning of the notification.

The Notification MBean has to maintain a table of listener, filter, and hand-back objects. When the MBean emits a  notification, it invokes the handleNotification method of all the registered NotificationListener objects, with their respective hand-back object.

 

Getting Notification Information

 

The method getNotificationInfo() in the NotificationBroadcaster  Interface gives a potential listener the description of all notifications this broadcaster may emit. This method returns an array of MBeanNotificationInfo objects, each of which describes a notification.

 

Removing a Notification Listener

 

The method removeNotificationListener() in the NotificationBroadcaster  Interface unregisters the listener from a notification  broadcaster. This method takes a reference to a NotificationListener object, as well as a hand-back object.

 

If the hand-back object is provided, only the entry corresponding to this listener and hand-back pair will be removed. The same listener object may still be registered with other hand-back objects.  If the hand-back is not provided, all entries corresponding to the listener will be removed.

      Note: As an alternative method of implementing Notifications, an MBean wanting to emit Notification can extend the Class NotificationBroadcasterSupport which implements the  NotificationBroadcaster Interface

8.3 Notification Types

 

The type of the Notification is assigned by the broadcaster object and conveys the semantic meaning of a particular notification. The type is given as a String field of the Notification object. This string is interpreted as any number of dot-separated components, allowing an arbitrary, user-defined structure in the naming of notification types.

Otherwise, notification broadcasters are free to define all types they wish to use when naming the notifications they emit. Usually, MBeans will use type strings that reflect the nature of their notifications within the larger management structure in which they are involved.

 

8.4 Sending Notifications

 

Notifications are send to all listeners registered with the Notification Broadcaster on the occurrence of an event. The event may be a change in state of managed resource or occurrence of a specific condition.  This is implementation specific.

To send Notifications, follow the steps given below:

8.5 Viewing Notifications

 

The Notification mechanism is designed to forward only notifications from registered MBeans on the agent side to proper listeners on the manager side.

 

Viewing Notifications Through RMI/CORBA/HTTP Adaptors

Similarly, you can connect to the CORBA client/HTTP client and view the generated notifications.

 

.

 

Viewing Notifications Through SNMP Adaptor

 

Viewing Notifications Through TL1 Adaptor

 

 
 

Copyright © 1996-2004, AdventNet Inc. All Rights Reserved.