public class Notification
extends java.lang.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 NotificationProvider
. 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.
Modifier and Type | Field and Description |
---|---|
java.util.Map<java.lang.String,java.lang.String> |
fields |
java.lang.String |
uniqueId |
Constructor and Description |
---|
Notification(java.lang.String uniqueId) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getField(java.lang.String name) |
java.util.Map<java.lang.String,java.lang.String> |
getFields() |
java.lang.String |
getUniqueId() |
void |
setField(java.lang.String name,
java.lang.String value) |
void |
setFields(java.util.Map<java.lang.String,java.lang.String> fieldMap) |
RecordItem |
toRecordItem(java.lang.String username,
java.lang.String sourceName) |
java.lang.String |
toString() |
public final java.lang.String uniqueId
public java.util.Map<java.lang.String,java.lang.String> fields
public Notification(java.lang.String uniqueId)
uniqueId
- Unique identifier for this Notification. This id is used when removing items from the NotificationChannel
and in the callback in NotificationChannelListener
.public java.lang.String getUniqueId()
public java.lang.String getField(java.lang.String name)
name
- Key associated with a value.public void setField(java.lang.String name, java.lang.String value)
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.public java.util.Map<java.lang.String,java.lang.String> getFields()
public void setFields(java.util.Map<java.lang.String,java.lang.String> fieldMap)
fieldMap
- Map of fields and values for this Notification. The field names must be present in the fields.conf used to configure the DataSource.public java.lang.String toString()
toString
in class java.lang.Object
public RecordItem toRecordItem(java.lang.String username, java.lang.String sourceName)
Please send bug reports and comments to Caplin support