ADLINK-IST / opensplice

This is the Vortex OpenSplice Community Edition source repository. For our commercial offering see
https://www.adlinktech.com/en/vortex-opensplice-data-distribution-service
Apache License 2.0
259 stars 157 forks source link

Question about Listener callback methods (Python) #126

Open solarjoe opened 4 years ago

solarjoe commented 4 years ago

The code states in dds.pyx states

def on_data_on_readers(self, subscriber):
    # Note 2: Per the DDS specification, registering this handler disables 
    # on_data_available() on all contained data readers.

I seem to encounter a similar "disabling" behavior for other callback methods, e.g.

on_publication_matched(self, writer, status)
on_subscription_matched(self, reader, status)
on_liveliness_changed(self, reader, status)
on_data_available(self, reader)

It seems that these are also disables sometimes, but I have not found a rule so far. Could it be that if a method is registered in a parent it is deactivated for all children?

e.g. if the listener for a DomainParticipant dp implements on_data_available it is not available in all listeners in Subscribers or DataReaders that have dp as parent?

vivekpandey02 commented 4 years ago

Dear SolarJoe,

Please see the below explanation: The Data Distribution Service will trigger the most specific and relevant Listener. In other words, in case a communication status is also activated on the Listener of a contained entity, the Listener on that contained entity is invoked instead of the DomainParticipantListener. This means that a status change on a contained entity only invokes the DomainParticipantListener if the contained entity itself does not handle the trigger event generated by the status change. The statuses DATA_ON_READERS_STATUS and DATA_AVAILABLESTATUS are “Read Communication Statuses” and are an exception to all other plain communication statuses: they have no corresponding status structure that can be obtained with a get_status operation and they are mutually exclusive. When new information becomes available to a DataReader, the Data Distribution Service will first look in an attached and activated SubscriberListener or DomainParticipantListener (in that order) for the DATA_ON_READERS_STATUS. In case the DATA_ON_READERS_STATUS can not be handled, the Data Distribution Service will look in an attached and activated DataReaderListener, SubscriberListener or DomainParticipant Listener for the DATA_AVAILABLE_STATUS (in that order).