Class Notification

java.lang.Object
com.caplin.datasource.notification.Notification

public class Notification extends Object

Notification represents a single notification to be sent to a client. It is identified by the uniqueId passed into the constructor. Methods are provided for setting field access.

Notifications are passed into the NotificationChannel.sendNotification(Notification) and NotificationChannel.sendNotifications(java.util.List<com.caplin.datasource.notification.Notification>) methods on the NotificationChannel received on NotificationApplicationListener callbacks.

The uniqueId is used in the subject in place of the '%i' in the '/PRIVATE/NOTIFICATIONS/DATASOURCES/%u/NOTIFY/[sourceName]-%i' notification namespace to create the record subject for this Notification. These notifications will be received by any listeners registered with a StreamLink Alerts API's NotificationService whereupon the uniqueId can be extracted.

When the Notification is sent on the NotificationChannel three fields are added to the notification. They include NotificationId, NotificationSource and NotificationTime. The NotificationSource is the source name that has been configured on the NotificationConfiguration. The NotificationId is set to "[source-name]-[uniqueId-of-notification]". The NotificationTime field will be set to the time in millis since 1970/01/01 at which the Notification is sent, however if this field has been set already using setField(String, String) then this set will be respected and the fields value won't be automatically replaced.

  • Field Details

  • Constructor Details

  • Method Details

    • getUniqueId

      public String getUniqueId()
      Returns:
      uniqueId The uniqueId this Notification was instantiated with.
    • getField

      public String getField(String name)
      Parameters:
      name - Key associated with a value.
      Returns:
      Value of this field.
    • setField

      public void setField(String name, String value)
      Parameters:
      name - Field name associate with a value. These must be present in the fields.conf used to configure the DataSource.
      value - Value to send associated with this field name.
    • getFields

      public Map<String,String> getFields()
      Returns:
      A map containing all fields present on this Notification.
    • setFields

      public void setFields(Map<String,String> fieldMap)
      Parameters:
      fieldMap - Map of fields and values for this Notification. The field names must be present in the fields.conf used to configure the DataSource.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      String containing this Notification's uniqueId and fields.
    • toRecordItem

      public com.caplin.container.RecordItem toRecordItem(String username, String sourceName)