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!
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 withDataReader::take()/read()/take/read_next_sample()
).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.
Thanks very much!
As you mentioned, with default QoS, any DataReader called
select().max_samples(1).state(dds::sub::status::DateState::any()) four
times will always get the samples in written order: { "A", 1 }, { "B", 1 }, { "A", 2 }, { "B", 2 }.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