From OpenNMS
When you register multiple EventListeners that are the same class with the an EventIpcManager it's easy to accidentally have multiple copies of events go to the first one you register, instead of one copy going to each EventListener.
The code to register an EventListener looks like this:
EventIpcManagerFactory.init(); EventIpcManagerFactory.getIpcManager().addEventListener(this, ueiList);
Where this is an instance of a class that implements the EventListener interface.
The EventListener interface has two methods:
- onEvent() which handles events as you might expect
- getName() which returns the EventListener's name
If your EventListener returns a constant name, you will end up with a single instance receiving events. You have to vary the name by adding an instance suffix to it or something to receive a single copy of each event at each EventListener.
For example:
/**
* Return an id for this event listener
*/
public String getName() {
return CLASS_NAME_CONSTANT + "_" + m_nameSuffix;
}
where m_nameSuffix is a loop index passed into the constructor.
The class EventIpcManagerDefaultImpl that actually handles the addEventListener treats addListener calls for EventListeners that return the same getName() value as a second registration of the same EventListener. It retrieves its existing thread that's associated with that name and registers it again.






