Package com.lightstreamer.client.mpn
Interface MpnSubscriptionListener
public interface MpnSubscriptionListener
Interface to be implemented to receive
Events for these listeners are dispatched by a different thread than the one that generates them. This means that, upon reception of an event, it is possible that the internal state of the client has changed. On the other hand, all the notifications for a single
MpnSubscription
events including subscription/unsubscription, triggering and status change.Events for these listeners are dispatched by a different thread than the one that generates them. This means that, upon reception of an event, it is possible that the internal state of the client has changed. On the other hand, all the notifications for a single
LightstreamerClient
, including
notifications to ClientListener
, SubscriptionListener
, ClientMessageListener
, MpnDeviceListener
and MpnSubscriptionListener
will be dispatched by the same thread.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Event handler called when the MpnSubscriptionListener instance is removed from anMpnSubscription
throughMpnSubscription.removeListener(MpnSubscriptionListener)
.
This is the last event to be fired on the listener.void
Event handler called when the MpnSubscriptionListener instance is added to anMpnSubscription
throughMpnSubscription.addListener(MpnSubscriptionListener)
.
This is the first event to be fired on the listener.void
onModificationError
(int code, String message, String propertyName) Event handler called when the value of a property ofMpnSubscription
cannot be changed.
Properties can be modified by direct calls to their setters.void
onPropertyChanged
(String propertyName) Event handler called each time the value of a property ofMpnSubscription
is changed.
Properties can be modified by direct calls to their setter or by server sent events.void
onStatusChanged
(String status, long timestamp) Event handler called when the server notifies that anMpnSubscription
changed its status.
Note that in some server clustering configurations the status change for the MPN subscription's trigger event may not be called.void
Event handler called when anMpnSubscription
has been successfully subscribed to on the server's MPN Module.
This event handler is always called before other events related to the same subscription.
Note that this event can be called multiple times in the life of an MpnSubscription instance only in case it is subscribed multiple times throughLightstreamerClient.unsubscribe(MpnSubscription)
andLightstreamerClient.subscribe(MpnSubscription, boolean)
.void
onSubscriptionError
(int code, String message) Event handler called when the server notifies an error while subscribing to anMpnSubscription
.
By implementing this method it is possible to perform recovery actions.void
Event handler called when the server notifies that anMpnSubscription
did trigger.
For this event to be called the MpnSubscription must have a trigger expression set and it must have been evaluated to true at least once.
Note that this event can be called multiple times in the life of an MpnSubscription instance only in case it is subscribed multiple times throughLightstreamerClient.unsubscribe(MpnSubscription)
andLightstreamerClient.subscribe(MpnSubscription, boolean)
.void
Event handler called when anMpnSubscription
has been successfully unsubscribed from on the server's MPN Module.
After this call no more events can be received until a newonSubscription()
event.
Note that this event can be called multiple times in the life of an MpnSubscription instance only in case it is subscribed multiple times throughLightstreamerClient.unsubscribe(MpnSubscription)
andLightstreamerClient.subscribe(MpnSubscription, boolean)
.void
onUnsubscriptionError
(int code, String message) Event handler called when the server notifies an error while unsubscribing from anMpnSubscription
.
By implementing this method it is possible to perform recovery actions.
-
Method Details
-
onListenStart
void onListenStart()Event handler called when the MpnSubscriptionListener instance is added to anMpnSubscription
throughMpnSubscription.addListener(MpnSubscriptionListener)
.
This is the first event to be fired on the listener. -
onListenEnd
void onListenEnd()Event handler called when the MpnSubscriptionListener instance is removed from anMpnSubscription
throughMpnSubscription.removeListener(MpnSubscriptionListener)
.
This is the last event to be fired on the listener. -
onSubscription
void onSubscription()Event handler called when anMpnSubscription
has been successfully subscribed to on the server's MPN Module.
This event handler is always called before other events related to the same subscription.
Note that this event can be called multiple times in the life of an MpnSubscription instance only in case it is subscribed multiple times throughLightstreamerClient.unsubscribe(MpnSubscription)
andLightstreamerClient.subscribe(MpnSubscription, boolean)
. Two consecutive calls to this method are not possible, as before a secondonSubscription()
event anonUnsubscription()
event is always fired. -
onUnsubscription
void onUnsubscription()Event handler called when anMpnSubscription
has been successfully unsubscribed from on the server's MPN Module.
After this call no more events can be received until a newonSubscription()
event.
Note that this event can be called multiple times in the life of an MpnSubscription instance only in case it is subscribed multiple times throughLightstreamerClient.unsubscribe(MpnSubscription)
andLightstreamerClient.subscribe(MpnSubscription, boolean)
. Two consecutive calls to this method are not possible, as before a secondonUnsubscription()
event anonSubscription()
event is always fired. -
onSubscriptionError
Event handler called when the server notifies an error while subscribing to anMpnSubscription
.
By implementing this method it is possible to perform recovery actions.- Parameters:
code
- The error code sent by the Server. It can be one of the following:- 17 - bad Data Adapter name or default Data Adapter not defined for the current Adapter Set.
- 21 - bad Group name.
- 22 - bad Group name for this Schema.
- 23 - bad Schema name.
- 24 - mode not allowed for an Item.
- 30 - subscriptions are not allowed by the current license terms (for special licenses only).
- 40 - the MPN Module is disabled, either by configuration or by license restrictions.
- 41 - the request failed because of some internal resource error (e.g. database connection, timeout, etc.).
- 43 - invalid or unknown application ID.
- 44 - invalid syntax in trigger expression.
- 45 - invalid or unknown MPN device ID.
- 46 - invalid or unknown MPN subscription ID (for MPN subscription modifications).
- 47 - invalid argument name in notification format or trigger expression.
- 48 - MPN device suspended.
- 49 - one or more subscription properties exceed maximum size.
- 50 - no items or fields have been specified.
- 52 - the notification format is not a valid JSON structure.
- 53 - the notification format is empty.
- 66 - an unexpected exception was thrown by the Metadata Adapter while authorizing the connection.
- 68 - the Server could not fulfill the request because of an internal error.
- <= 0 - the Metadata Adapter has refused the subscription request; the code value is dependent on the specific Metadata Adapter implementation.
message
- The description of the error sent by the Server; it can be null.
-
onUnsubscriptionError
Event handler called when the server notifies an error while unsubscribing from anMpnSubscription
.
By implementing this method it is possible to perform recovery actions.- Parameters:
code
- The error code sent by the Server. It can be one of the following:- 30 - subscriptions are not allowed by the current license terms (for special licenses only).
- 40 - the MPN Module is disabled, either by configuration or by license restrictions.
- 41 - the request failed because of some internal resource error (e.g. database connection, timeout, etc.).
- 43 - invalid or unknown application ID.
- 45 - invalid or unknown MPN device ID.
- 46 - invalid or unknown MPN subscription ID.
- 48 - MPN device suspended.
- 66 - an unexpected exception was thrown by the Metadata Adapter while authorizing the connection.
- 68 - the Server could not fulfill the request because of an internal error.
- <= 0 - the Metadata Adapter has refused the unsubscription request; the code value is dependent on the specific Metadata Adapter implementation.
message
- The description of the error sent by the Server; it can be null.
-
onTriggered
void onTriggered()Event handler called when the server notifies that anMpnSubscription
did trigger.
For this event to be called the MpnSubscription must have a trigger expression set and it must have been evaluated to true at least once.
Note that this event can be called multiple times in the life of an MpnSubscription instance only in case it is subscribed multiple times throughLightstreamerClient.unsubscribe(MpnSubscription)
andLightstreamerClient.subscribe(MpnSubscription, boolean)
. Two consecutive calls to this method are not possible.
Note also that in some server clustering configurations this event may not be called. The corrisponding push notification is always sent, though.- See Also:
-
onStatusChanged
Event handler called when the server notifies that anMpnSubscription
changed its status.
Note that in some server clustering configurations the status change for the MPN subscription's trigger event may not be called. The corresponding push notification is always sent, though.- Parameters:
status
- The new status of the MPN subscription. It can be one of the following:UNKNOWN
ACTIVE
SUBSCRIBED
TRIGGERED
timestamp
- The server-side timestamp of the new subscription status.- See Also:
-
onPropertyChanged
Event handler called each time the value of a property ofMpnSubscription
is changed.
Properties can be modified by direct calls to their setter or by server sent events. A propery may be changed by a server sent event when the MPN subscription is modified, or when two MPN subscriptions coalesce (seeLightstreamerClient.subscribe(MpnSubscription, boolean)
).- Parameters:
propertyName
- The name of the changed property. It can be one of the following:mode
group
schema
adapter
notification_format
trigger
requested_buffer_size
requested_max_frequency
status_timestamp
-
onModificationError
Event handler called when the value of a property ofMpnSubscription
cannot be changed.
Properties can be modified by direct calls to their setters. SeeMpnSubscription.setNotificationFormat(String)
andMpnSubscription.setTriggerExpression(String)
.- Parameters:
code
- The error code sent by the Server.message
- The description of the error sent by the Server.propertyName
- The name of the changed property. It can be one of the following:notification_format
trigger
-