Interface NotificationChannel

All Known Implementing Classes:
NotificationChannelImpl

public interface NotificationChannel

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 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

      void removeNotification(String uniqueId)

      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

      void removeNotifications(List<String> uniqueIds)

      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

      void sendNotification(Notification notification)

      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

      void sendNotificationNotFound(String uniqueId)

      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

      void sendNotifications(List<Notification> items)

      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

      void sendNotificationStatusOk(String uniqueId)

      Send status ok for a Notification.

      Under normal circumstances this method is not used.

      Parameters:
      uniqueId - of the message whose status is OK
    • sendNotificationStatusStale

      void sendNotificationStatusStale(String uniqueId)

      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 no Notifications to be added for the channel. I.e. A NotificationApplicationListener.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

      void setNotificationChannelListener(NotificationChannelListener listener)

      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