Creating Subscribers Explicitly vs. Implicitly

To receive data, your application must have a Subscriber. However, you are not required to explicitly create a Subscriber. If you do not create one, the middleware will implicitly create a Subscriber the first time you create a DataReader using the DomainParticipant’s operations. It will be created with default QoS (DDS_SUBCRIBER_QOS_DEFAULT) and no Listener. The 'implicit Subscriber' can be accessed using the DomainParticipant’s get_implicit_subscriber() operation (see Getting the Implicit Publisher or Subscriber).You can use this ‘implicit Subscriber’ just like any other Subscriber (it has the same operations, QosPolicies, etc.). So you can change the mutable QoS and set a Listener if desired.

A Subscriber (implicit or explicit) gets its own default QoS and the default QoS for its child DataReaders from the DomainParticipant. These default QoS are set when the Subscriber is created. (This is true for Publishers and DataWriters, too.)

DataReaders are created by calling create_datareader() or create_datareader_with_profile()—these operations exist for DomainParticipants and Subscribers1In the Modern C++ API, you always use a DataReader constructor.. If you use the DomainParticipant to create a DataReader, it will belong to the implicit Subscriber. If you use a Subscriber to create a DataReader, it will belong to that Subscriber.

The middleware will use the same implicit Subscriber for all DataReaders that are created using the DomainParticipant’s operations.

Having the middleware implicitly create a Subscriber allows you to skip the step of creating a Subscriber. However, having all your DataReaders belong to the same Subscriber can reduce the concurrency of the system because all the read operations will be serialized.

© 2018 RTI