OSGi Event Listener
The OSGi Event Listener allows the user to get the OSGi Events from the Talend Runtime Container which are published via the EventAdmin service.
To enable Event Logging via the OSGi Listener, only the related listener bundle needs to be started. No other container related configuration is required by our standard Talend Runtime Container.
The OSGi Event Listener is implemented using Apache Camel, via the eventadmin: component, and provides a configurable Topic Filter and Category Mapper with a Direct-VM communication to the Talend Event Logging Agent.
The eventadmin: component has a fixed configuration to listen (subscribe) to all topics: eventadmin:*. Talend ESB provides an easy-to-use Topic Filter within the OSGi Event Listener. In the configuration, the user can provide a list of topics to be included and/or excluded, including the use of "*" for all.
filter.include.*
filter.include.org/osgi/service
filter.exclude.org/osgi
The Topic Filter allows the user to quickly include and/or exclude all and/or just a few selected ones. As shown in the example, each topic, or partial topic, requires a row. And if an included topic matches the current topic, it will be included, as long as it is not matching an excluded topic.
Inclusion has priority before exclusion is evaluated.
Example:
In the example above, all events are included, except the one which starts with org/osgi/. But within the org/osgi/ topics, the ones in the org/osgi/service/ sub-topic will be included.
The OSGi Event -> Event conversion step will transform the OSGi Event into the Event (Logging) format, where the Event Structure is as completely filled as possible, and the additional metadata (including the OSGi Event Properties) is transformed in the Event Customer Information (Key, Value) list.
The Category Mapper allows the user to define an Event Logging category in a configurable way for the OSGi Event, based on the OSGi Event topic, and if this event should be treated as an audit event or not.
The configuration related to the Category Mapper is as follows:
# Default category for events
category.default=osgi
category.attribute=eventCategory
audit.attribute=watchThis
# Category mapping configuration
category.mapping.org/osgi/framework/ServiceEvent=service
category.mapping.org/osgi/service=service(audit=true)
The priority is defined by the log Category Mapper.
After this step, the OSGi Event message is sent to the Event Logging Agent in a synchronous way (Direct-VM) to allow the agent to do a short pre-processing before the event is stored into a local buffer within the agent for final processing and sending to the backend.
The OSGi Event Listener uses the org.talend.eventlogging.listener.osgi.cfg configuration file with the following parameters:
# Default category for events
category.default=osgi
# Name of key used to get events
category.attribute=eventCategory
audit.attribute=audit
# Category mapping configuration
category.mapping.org/osgi/framework/ServiceEvent=service
#category.mapping.org/osgi/service=service(audit=true)
# Filter configuration, by default, all events are included except
# the one defined in the filter.include. properties
filter.exclude.*
filter.include.org/osgi/framework/ServiceEvent
filter.include.org/osgi/framework/BundleEvent
filter.include.org/osgi/framework/FrameworkEvent
Similar to the Log Listener, it will allow to set the audit flag based on the audit.attribute, which is here an OSGi Property, and/or on the Category Mapping. In the current version of Talend ESB, it is the only property which can be set as part of the mapping, but in future versions, the attribute=value notation would allow to extend this to other attributes: attribute1=value1; attribute2=value2; custominfo={{key1, value1}{key2, value2}}.