JMX notifications from MC4J/EMS

Elias Ross genman at noderunner.net
Fri May 13 01:02:39 UTC 2011


Hi.

So I'm considering adding support for JMX notifications in RHQ.

>From what I can tell, the steps are basically:

1. For each EmsBean.getNotifications() (returns set of interface
EmsNotification).
2. Determine if we should listen or not to its notifications (through
configuration? always?) Not sure how to indicate in XML this detail.
3. Pass MBeanResourceComponent (implementing EmsNotificationListener)
to EmsNotification.addNotificationListener
4. Call EmsNotification.startListening ...
5. At stop time, ensure EmsNotification.stopListening is called
6. As for how the events get to RHQ, essentially it involves calling

org.rhq.core.pluginapi.event.EventContext.publishEvent( ... )

And a reference to EventContext is obtained through initialization.

One problem I see is the DNotification instance currently captures
every event in member variable "events", which looks like a big memory
leak waiting to happen... This is the only times "events" is
referenced in the class.

public class DNotification implements EmsNotification {

    protected List<EmsNotificationEvent> events = new
ArrayList<EmsNotificationEvent>();

    public List<EmsNotificationEvent> getEvents() {
        return Collections.unmodifiableList(events);
    }

    protected void fireNotifications(EmsNotificationEvent event) {
        events.add(event);
...
    }

So I think what needs to happen is modification of this class. If
there are no listeners, then maybe capture the event (still sounds
bad); otherwise the event is passed on.


More information about the rhq-devel mailing list