Interface NotificationChannel
- All Known Implementing Classes:
NotificationChannelImpl
The NotificationChannel is a notification communication channel associated with a particular user. It allows your application to add and remove
Notification
s for a user which will be received by a front end application.
The channel caches all sent messages and handles requests for cached Notifications automatically.
When a notification is removed, it is removed from the cache and the user is automatically unsubscribed from it.
It enters your application through the NotificationApplicationListener.notificationChannelOpened(com.caplin.datasource.notification.NotificationChannel)
callback.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Closes the channel.Returns the subject for the channel.Returns the username for the channelvoid
removeNotification
(String uniqueId) Removes theNotification
from the internal cache and sends a container remove so that this notification is no longer requested when the channel is subscribed to.void
removeNotifications
(List<String> uniqueIds) RemovesNotification
s from the internal cache and sends a container remove so that these notifications are no longer requested when the channel is subscribed to.void
Sends an empty container on the channel.void
sendNotification
(Notification notification) Adds theNotification
to the internal cache and sends a container add so that this notification is requested when the channel is subscribed to.void
Sends a status ok on the channel.void
Sends a status stale on the channel.void
sendNotificationNotFound
(String uniqueId) Sends a not found for aNotification
.void
sendNotifications
(List<Notification> items) AddsNotification
s to the internal cache and sends a container add so that these items are requested when the channel is subscribed to.void
sendNotificationStatusOk
(String uniqueId) Send status ok for aNotification
.void
sendNotificationStatusStale
(String uniqueId) Send status stale for aNotification
.void
Your application SHOULD set aNotificationChannelListener
on the channel.
-
Method Details
-
closeChannel
void closeChannel()Closes the channel.
Sends a Subject Not Found on the channel's subject to let subscribers know that it is no longer serviced.
-
getSubject
String getSubject()Returns the subject for the channel.
- Returns:
- subject for the channel
-
getUsername
String getUsername()Returns the username for the channel
- Returns:
- username for the channel
-
removeNotification
Removes the
Notification
from the internal cache and sends a container remove so that this notification is no longer requested when the channel is subscribed to.- Parameters:
uniqueId
- of the item to remove
-
removeNotifications
Removes
Notification
s from the internal cache and sends a container remove so that these notifications are no longer requested when the channel is subscribed to.- Parameters:
uniqueIds
- of the items to remove
-
sendNotification
Adds the
Notification
to the internal cache and sends a container add so that this notification is requested when the channel is subscribed to.If an notification with the same unique id already exists in the internal cache then that item's fields will be updated with this one's. This will then trigger an update for any users currently subscribed to this item.
- Parameters:
notification
- to send
-
sendNotificationNotFound
Sends a not found for a
Notification
.Specifically for the case where there is more than one NotificationProvider.
Sent in response to a
NotificationChannelListener.onNotificationRequest(com.caplin.datasource.notification.NotificationChannel, java.lang.String)
when the item requested is not serviceable by your application.- Parameters:
uniqueId
- of item that cannot be serviced by your application.
-
sendNotifications
Adds
Notification
s to the internal cache and sends a container add so that these items are requested when the channel is subscribed to.If any items with the same unique id already exists in the internal cache then these items fields will be updated with these one. This will then trigger an update for any users currently subscribed to these items.
- Parameters:
items
- to send
-
sendNotificationStatusOk
Send status ok for a
Notification
.Under normal circumstances this method is not used.
- Parameters:
uniqueId
- of the message whose status is OK
-
sendNotificationStatusStale
Send status stale for a
Notification
.Under normal circumstances this method is not used.
- Parameters:
uniqueId
- of the message whose status is STALE
-
sendNotificationContainerStatusOk
void sendNotificationContainerStatusOk()Sends a status ok on the channel.
Under normal circumstances this method is not used.
-
sendNotificationContainerStatusStale
void sendNotificationContainerStatusStale()Sends a status stale on the channel.
Under normal circumstances this method is not used.
-
sendEmptyNotificationContainer
void sendEmptyNotificationContainer()Sends an empty container on the channel.
Invoke when a
NotificationApplicationListener.notificationChannelOpened(com.caplin.datasource.notification.NotificationChannel)
callback is received and there are currently noNotification
s to be added for the channel. I.e. ANotificationApplicationListener.notificationChannelOpened(com.caplin.datasource.notification.NotificationChannel)
for a historic trade data NotificationChannel for a user who has not yet traded would be serviced with this method. -
setNotificationChannelListener
Your application SHOULD set a
NotificationChannelListener
on the channel. On this listener, your application will receive callbacks on requests for Notifications not in the cache and when a front-end client sends actions in response to the notification.See
NotificationConfiguration
for information about having a distributed notification provision, the scenario where a request could come in for an item not in cache.- Parameters:
listener
- to receive requests for items not already cached by the NotificationAPI
-