Will the different instances be delivered to DataReader in write time order strictly?

5 posts / 0 new
Last post
Offline
Last seen: 1 month 3 weeks ago
Joined: 10/09/2022
Posts: 7
Will the different instances be delivered to DataReader in write time order strictly?

Suppose the following IDL:

struct Data {

    string name; //@key

    long id;

}

A DataWriter writes the following samples in time order:
{ "A", 1 }, { "B", 1 }, { "A", 2 }, { "B", 2 }

For  RELIABLE_RELIABILITY_QOS, will RTI DDS guarantees that the reader application take the samples in the write time order?
Or the samples may be sorted by key, such as: { "A", 1 }, { "A", 2 }, { "B", 1 }, { "B", 2 }

And what about the late-joining DataReaders?

Thanks!

Keywords:
Howard's picture
Offline
Last seen: 6 hours 59 min ago
Joined: 11/29/2012
Posts: 447

Depending on which API that you use to take/read data from a DataReader, you can do it by instance ( DataReader::take/read_instance()/take/read_next_instance(), so each call only returns the samples that have been received for a particular instance, or by time received (with default DestinationOrder setting), which is the order in which a single DataWriter sent the data with DataReader::take()/read()/take/read_next_sample()).

Gerardo Pardo's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 06/02/2010
Posts: 600

This behavior is controlled by the PRESENTATION Qos Policy on the Publisher and the Subscriber. Specifically the settings for scope and access_control.

With the default Qos settings ordering accross instances (different key values) is not guaranteed to be kept, only order within each instance is guaranteed. Some DataReader APIs like read() / take(), which return unconstrained sequences, will return samples in the same order they were written and some other DataReader APIs (e.g. read_by_instance()) will not. But this is more of an implementation issue since the default setting of the Qos does not specify that the order should be kept.

To ensure data on different instances is received by a DataReader in the same order that was written by the DataWriter modify the PRESENTATION Qos Policy on both Publisher and Subscriber and set the access_scope to TOPIC and the ordered_access to TRUE.

Offline
Last seen: 1 month 3 weeks ago
Joined: 10/09/2022
Posts: 7

Thanks very much!

Some DataReader APIs like read() / take(), which return unconstrained sequences, will return samples in the same order they were written

 

As you mentioned, with default QoS, any DataReader called select().max_samples(1).state(dds::sub::status::DateState::any()) fourtimes will always get the samples in written order: { "A", 1 }, { "B", 1 }, { "A", 2 }, { "B", 2 }.

Offline
Last seen: 1 month 2 weeks ago
Joined: 07/08/2021
Posts: 6

Hi, 

For your reference, you can refer to the below to see how to use the various read/take APIs to read data

https://community.rti.com/static/documentation/connext-dds/7.0.0/doc/manuals/connext_dds_professional/users_manual/users_manual/PartReceivingData.htm