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(Notifications2Properties notifications2Properties, String tenantId, NotificationSubscriptionApi notificationSubscriptionApi, TokenApi tokenApi) -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(Subscription.ID subscriptionId) Used to clean up platform resources created for given subscription.voiddisconnect(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 subscriptionvoidsubscribe(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(Notifications2Properties notifications2Properties, String tenantId, NotificationSubscriptionApi notificationSubscriptionApi, TokenApi tokenApi)
-
-
Method Details
-
subscribe
Description copied from interface:Notifications2ApiMakes new subscription based on requested definition.
If connection is already existing and active,Notifications2SubscriptionAlreadyEstablishedExceptionwill be thrown- Specified by:
subscribein interfaceNotifications2Api- Parameters:
subscription- subscription definitionlistener- notification listener
-
disconnect
Description copied from interface:Notifications2ApiCloses server connection and stops given subscription
If connection is not existing or not active, nothing will happen.- Specified by:
disconnectin 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:Notifications2ApiUsed 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:
deletein interfaceNotifications2Api- Parameters:
subscriptionId- subscription identifier to delete
-
getRawWebSocket
Description copied from interface:Notifications2ApiFinds and returns low-level web socket object if one was created for subscription- Specified by:
getRawWebSocketin interfaceNotifications2Api- Parameters:
subscriptionId- subscription identifier
-