This chapter discuses how an event or notification service-based application (or any event aware application in general) can use VisiTelcoLog Service to log events. VisiTelcoLog Service is basically an event logger. Log, in this context, is an event channel that propagates events apart from logging the events to a persistent store.
•
• Using log factories to obtain event based log objects.
• Logging events on event based log objects.
• Forwarding logged events to consumers.
• Filtering events to be logged.For an event aware application that wishes to log events, an event-based log is first bootstrapped using the log's factory. For example, a notification service-based application first resolves to NotifyLogFactory using the object name NotifyLogService, and then obtains a log of type NotifyLog. For other types of event-based applications, see the table above. This section explains the steps to be taken to obtain reference to an event-based log object.The example code below first bootstraps to NotifyLogFactory using the object name NotifyLogService. It then attempts to find a NotifyLog log with ID equal to 100 from the factory. If it does not find NotifyLog it attempts to create one. The maximum size specified is 0 (zero). This means that no predefined limit is used; however, a predefined limit is recommended.The example code is located in the <install_dir>/examples/vbe/telcolog/primitive_cpp directory.Example code is located in the <install_dir>/examples/vbe/telcolog/primitive_java directory.Once the reference to the event-based log object is resolved, an event propagation (or forwarding) operation such as push or pull is used to propagate events. Since this channel object also has the characteristics of a log, it logs all the events that are propagated through it. Filters can also be attached to the log. See “Filtering events” for further details on how to selectively log events.For further details on developing Notification Service supplier applications, see the Developing supplier and consumer applications section in the VisiBroker VisiNotify Guide.On a log full condition, if the log full action is set to wrap, then the oldest events are over-written. If the log full action is set to halt, and if the log record expire time is specified, then all the expired events are over-written. Otherwise the following exceptions are thrown:
• Insufficient space: If the log space is not sufficient for logging the event then a NO_RESOURCE system exception with LOGFULL minor code (1001) is thrown.
• Off-duty log: If the log is off-duty then a NO_RESOURCE system exception with minor code LOGOFFDUTY (1000) is thrown.
• Locked log: If the log is locked then a NO_PERMISSION system exception with minor code LOGLOCKED (1003) is thrown.
• Disabled log: If the log is disabled, then TRANSIENT system exception with minor code equal to LOGDISABLED (1002) is thrown.Note that if the supplier is using event batching the exceptions will not reach the supplier. See the “VisiBroker Event Buffering/Batch” section in the VisiBroker VisiNotify Guide for further details on event batching.Also note that for the connected pull suppliers, the channel pulls the events and then logs those events. On a log full condition, the channel continually attempts to log until log space is available. There is no way the connected supplier application can know about this condition. Using the vbroker.dslog.waitForLogAvailable property a wait period can be specified for this loop. By default it is 20 seconds.Example code is located in the <install_dir>/examples/vbe/telcolog/primitive_cpp directory.Example code is located in the <install_dir>/examples/vbe/telcolog/primitive_java directory.The events that get pushed into a log or pulled by the log are forwarded to any down-stream consumers after the events are logged. Any consumer application can start consuming events that are propagated. See the Developing supplier and consumer applications section in the VisiBroker VisiNotify Guide for information on writing consumer applications.By setting its forwarding state to off, the log object can be configured so that it does not forward logged events. The following code snippet shows how an application can disable forwarding on a NotifyLog object and check the current forwarding state of the log.A filter set for a NotifyLog or a TypedNotifyLog can also filter events being logged to the log. The log uses the filter object defined by the notification service, CosNotifyFilter::Filter. See Setting the Quality of Service and Filters in the VisiBroker VisiNotify Guide for information about how to create a filter and how to write constraints.Note that only one filter object can be associated with a log. By default, no filter objects are associated with the log and all events are logged. Also, whenever a set_filter() method is called the log will generate an AttributeValueChange event.