Class Notifications2ApiImpl
java.lang.Object
com.cumulocity.sdk.client.notification2.internal.Notifications2ApiImpl
- All Implemented Interfaces:
Notifications2Api
Implements
There are two main components encapsulating notifications logic:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNotifications2ApiImpl
(String baseUrl, String tenantId, NotificationSubscriptionApi notificationSubscriptionApi, TokenApi tokenApi) -
Method Summary
Modifier and TypeMethodDescriptionvoid
delete
(Subscription.ID subscriptionId) Used to clean up platform resources created for given subscription.void
disconnect
(Subscription.ID subscriptionId, boolean unsubscribe) Closes server connection and stops given subscription
If connection is not existing or not active, nothing will happen.getRawWebSocket
(Subscription.ID subscriptionId) Finds and returns low-level web socket object if one was created for subscriptionvoid
subscribe
(Subscription subscription, NotificationListener listener) Makes new subscription based on requested definition.
-
Field Details
-
CONTEXT_DEVICE
- See Also:
-
CONTEXT_TENANT
- See Also:
-
-
Constructor Details
-
Notifications2ApiImpl
public Notifications2ApiImpl(String baseUrl, String tenantId, NotificationSubscriptionApi notificationSubscriptionApi, TokenApi tokenApi)
-
-
Method Details
-
subscribe
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 interfaceNotifications2Api
- Parameters:
subscription
- subscription definitionlistener
- notification listener
-
disconnect
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 interfaceNotifications2Api
- Parameters:
subscriptionId
- subscription identifier to unsubscribeunsubscribe
- true if token should be unsubscribed (only taken into account for persistent targets)
-
delete
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 interfaceNotifications2Api
- Parameters:
subscriptionId
- subscription identifier to delete
-
getRawWebSocket
Description copied from interface:Notifications2Api
Finds and returns low-level web socket object if one was created for subscription- Specified by:
getRawWebSocket
in interfaceNotifications2Api
- Parameters:
subscriptionId
- subscription identifier
-