Class Notifications2ApiImpl

java.lang.Object
com.cumulocity.sdk.client.notification2.internal.Notifications2ApiImpl
All Implemented Interfaces:
Notifications2Api

public class Notifications2ApiImpl extends Object implements Notifications2Api
Implements Notifications2Api based on our latest Core/Pulsar magic. Hides most of the complexity from the final subscriber.

There are two main components encapsulating notifications logic:
  • this class - keeps internal subscriptions cache and creates necessary platform objects
  • WebSocketClient - created for each subscription, responsible for establishing and maintaining websocket connection and tokens management
  • Field Details

  • Constructor Details

  • Method Details

    • subscribe

      public void subscribe(Subscription subscription, NotificationListener listener)
      Description copied from interface: Notifications2Api
      Makes new subscription based on requested definition.

      If connection is already existing and active, Notifications2SubscriptionAlreadyEstablishedException will be thrown
      Specified by:
      subscribe in interface Notifications2Api
      Parameters:
      subscription - subscription definition
      listener - notification listener
    • disconnect

      public void disconnect(Subscription.ID subscriptionId, boolean unsubscribe)
      Description copied from interface: Notifications2Api
      Closes server connection and stops given subscription

      If connection is not existing or not active, nothing will happen.
      Specified by:
      disconnect in interface Notifications2Api
      Parameters:
      subscriptionId - subscription identifier to unsubscribe
      unsubscribe - true if token should be unsubscribed (only taken into account for persistent targets)
    • delete

      public void delete(Subscription.ID subscriptionId)
      Description copied from interface: Notifications2Api
      Used to clean up platform resources created for given subscription.

      WARNING! Please be aware that deleting subscription will close all of its connections - even from other applications (i.e. instances of the same microservice).
      Specified by:
      delete in interface Notifications2Api
      Parameters:
      subscriptionId - subscription identifier to delete
    • getRawWebSocket

      public Optional<Object> getRawWebSocket(Subscription.ID subscriptionId)
      Description copied from interface: Notifications2Api
      Finds and returns low-level web socket object if one was created for subscription
      Specified by:
      getRawWebSocket in interface Notifications2Api
      Parameters:
      subscriptionId - subscription identifier