You are here: Part 2: Core Concepts > Sending Data > Publishers > Creating Publishers Explicitly vs. Implicitly

Creating Publishers Explicitly vs. Implicitly

To send data, your application must have a Publisher. However, you are not required to explicitly create one. If you do not create one, the middleware will implicitly create a Publisher the first time you create a DataWriter using the DomainParticipant’s operations. It will be created with default QoS (DDS_PUBLISHER_QOS_DEFAULT) and no Listener.

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

The 'implicit Publisher' can be accessed using the DomainParticipant’s get_implicit_publisher() operation (see Getting the Implicit Publisher or Subscriber). You can use this ‘implicit Publisher’ just like any other Publisher (it has the same operations, QosPolicies, etc.). So you can change the mutable QoS and set a Listener if desired.

DataWriters are created by calling create_datawriter() or create_datawriter_with_profile()—these operations exist for DomainParticipants and Publishers. If you use the DomainParticipant to create a DataWriter, it will belong to the implicit Publisher. If you use a Publisher to create a DataWriter, it will belong to that Publisher.

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

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

© 2016 RTI