Class Notification
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
com.caplin.container.RecordItem
toRecordItem
(String username, String sourceName) toString()
-
Field Details
-
uniqueId
-
fields
-
-
Constructor Details
-
Notification
- Parameters:
uniqueId
- Unique identifier for this Notification. This id is used when removing items from theNotificationChannel
and in the callback inNotificationChannelListener
.
-
-
Method Details
-
getUniqueId
- Returns:
- uniqueId The uniqueId this Notification was instantiated with.
-
getField
- Parameters:
name
- Key associated with a value.- Returns:
- Value of this field.
-
setField
- 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
- Returns:
- A map containing all fields present on this Notification.
-
setFields
- 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
-
toRecordItem
-