When sending IBM Director events, it is important to remember that the event types must first be published before the event is sent.
Event types are strings that represent the event's place in a hierarchy of event types. The event type also identifies a specific kind of failure such as a fan failure. Events are formatted similar to the following example:
"family1.qualifier1.qualifier2"
The '.' character is a delimiter. The family is always the first item in the string. It should uniquely define either an extension, or a type of hardware as the source. After the family is a '.' followed by one or more qualifiers.
Events also contain details about the problem. For instance, if you were sending an event that indicated that a battery is low, then the event details might contain the time until the battery will fail.
To publish an event type with it's details, use code like this:
static final FAMILY = "bobco"; String[] qualifiers = { "part1", "subpart2", "toolow" }; private static final String KEY_TEXT_JOB_SUCCESS = "resourcebundlekey1"; private static final String RESOURCE_BUNDLE = "com.bobco.BobCoResourceBundle"; private static final int PUBLISH_VERSION = 1; String[] keywords = { "part1resourcebundlekey", "subpart2", "toolow" TWGPublishEventType publish = new TWGPublishEventType(FAMILY, qualifiers, PUBLISH_VERSION, keywords, RESOURCE_BUNDLE, TWGPublishEventType.KEYWORD_3_ISA_LITERAL ); // publish by enqueueing to the event router TWGEventRouter.enqueuePublish( publish ); TWGPublishDetail publishDetail = new TWGPublishDetail( TWGBaseEvent.BOSSMAN, qualifiers, PUBLISH_VERSION, Locale.getDefault()); publishDetail.addDetail(new TWGDetail(JOB_SLOT_ID, JOB_SLOT_ID, JOB_SLOT_ID, TWGDetail.TYPE_STRING)); publishDetail.addDetail( new TWGDetail(JOB_ACTIVE_TIME_SLOT_ID, JOB_ACTIVE_TIME_SLOT_ID, JOB_ACTIVE_TIME_SLOT_ID, TWGDetail.TYPE_DATETIME)); TWGEventRouter.enqueuePublish( publishDetail );
To send an event from your IBM Director Server extension, use code like the following example:
static final FAMILY = "bobco"; String[] qualifiers = { "part1", "subpart2", "toolow" }; private static final String KEY_TEXT_JOB_SUCCESS = "resourcebundlekey1"; private static final String RESOURCE_BUNDLE = "com.bobco.BobCoResourceBundle"; String[] textVariables = { "substitution1", "substitution2" }; String eventTextTemplate = resourceBundle.getString( KEY_TEXT_JOB_SUCCESS ); private static byte[] serverIdentifier = ServiceNode.LocalUniqueID(); TWGBaseEvent event = new TWGBaseEvent( FAMILY, qualifiers, TWGBaseEvent.EVENT_SEVERITY_HARMLESS, moid, serverIdentifier, eventTextTemplate, Locale.getDefault(), textVariables, null, /* correlator */ 0 ); event.setTextKeywordAndBundleName( KEY_TEXT_JOB_SUCCESS, RESOURCE_BUNDLE ); // Event details contain extra information about the event event.addEventDetail( new TWGEventDetail( JOB_SLOT_ID, label) ); event.addEventDetail( new TWGEventDetail( JOB_ACTIVE_TIME_SLOT_ID, activation.GetDate() ) ); // send the event by enqueuing it to the eventrouter TWGEventRouter.enqueueEvent( managedObject, event );