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
Notifications 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 TypeMethodDescriptionvoidCloses the channel.Returns the subject for the channel.Returns the username for the channelvoidremoveNotification(String uniqueId) Removes theNotificationfrom the internal cache and sends a container remove so that this notification is no longer requested when the channel is subscribed to.voidremoveNotifications(List<String> uniqueIds) RemovesNotifications from the internal cache and sends a container remove so that these notifications are no longer requested when the channel is subscribed to.voidSends an empty container on the channel.voidsendNotification(Notification notification) Adds theNotificationto the internal cache and sends a container add so that this notification is requested when the channel is subscribed to.voidSends a status ok on the channel.voidSends a status stale on the channel.voidsendNotificationNotFound(String uniqueId) Sends a not found for aNotification.voidsendNotifications(List<Notification> items) AddsNotifications to the internal cache and sends a container add so that these items are requested when the channel is subscribed to.voidsendNotificationStatusOk(String uniqueId) Send status ok for aNotification.voidsendNotificationStatusStale(String uniqueId) Send status stale for aNotification.voidYour application SHOULD set aNotificationChannelListeneron 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
Notificationfrom 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
Notifications 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
Notificationto 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
Notifications 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 noNotifications 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
NotificationChannelListeneron 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
NotificationConfigurationfor 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
-