Create as Few Publishers and Subscribers as Possible

A DDS Publisher and Subscriber are responsible for sending and receiving the data. A Publisher contains one or multiple DataWriters.  A Subscriber contains one or multiple DataReaders.

Most often, an application will contain a single DomainParticipant, which contains one Subscriber with one or multiple DataReaders, and one Publisher with one or multiple DataWriters. 

There are several scenarios where you may want to have multiple Subscribers, each with their set of DataReaders (or multiple Publishers, each with their set of DataWriters): 

  1. Create multiple Subscribers or Publishers when you want to specify different QoS policies. The most common case is when you have DataReader or DataWriters belonging to different DDS Partitions.
  2. Create multiple Subscribers or Publishers to increase concurrency (at the expense of slight memory increase). DataReaders belonging to the same Subscriber cannot receive samples concurrently. In addition to creating multiple Subscribers, to increase concurrency, it is important to also specify different receive ports for specific DataReaders (using the TransportUnicast QoS Policy) as an additional receive thread will be created.

Note for the most advanced users of RTI Connext DDS: Even though you specify a different receive port (and hence create a new receive thread) for DataReaders within the same Subscriber, the level of concurrency remains at the granularity of the Subscriber. 

DataWriters belonging to the same Publisher cannot be used concurrently. Even if the application uses different threads to write with different DataWriters the calls to the write operations will be serialized. In addition to creating multiple Publishers, to increase concurrency in DataWriters configured with RELIABLE_RELIABILITY_QOS, it is important to also specify different receive ports for specific DataWriters (using the TransportUnicast QoS Policy), as an additional receive thread to process ACK traffic will be created.

 

Other  similar  links:

1. http://community.rti.com/kb/should-i-combine-my-datareaders-under-one-subscriber-or-use-separate-subscribers