QoS Introduction
After your first publisher/subscriber application is running, the next step is controlling communication behavior with Quality of Service (QoS).
QoS policies define how data is delivered, retained, and monitored in DDS.
Why QoS Matters
The same topic can be configured for different system goals:
- Low latency telemetry
- Guaranteed command delivery
- Late-joiner state replay
- Failover between primary and backup writers
QoS lets you tune behavior without redesigning your topic model.
Core QoS Concepts
Reliability
Controls delivery guarantees.
- BEST_EFFORT: lower overhead, samples may be dropped
- RELIABLE: retransmission and stronger delivery guarantees
Durability
Controls what late-joining readers receive.
- VOLATILE: only live traffic
- TRANSIENT_LOCAL: recent history from active writers
- TRANSIENT and PERSISTENT: longer-lived historical data
History
Controls how many samples are stored.
- KEEP_LAST: bounded history depth
- KEEP_ALL: retain all samples, constrained by resource limits
Deadline
Defines the expected maximum time between updates.
Use this to detect timing misses on periodic data streams.
Liveliness
Defines how readers detect that writers are still alive.
Useful for heartbeat-like supervision and failover behavior.
Ownership
Defines behavior when multiple writers publish the same keyed instance.
- SHARED: all writers contribute
- EXCLUSIVE: highest ownership strength wins
Typical Starting Profile
For a first production-style setup:
- Reliability: RELIABLE
- Durability: TRANSIENT_LOCAL
- History: KEEP_LAST with depth 10
- Deadline: set to your expected publish period
Applying QoS in Code
The core API flow is:
- Create a QoS object (
DataWriterQosorDataReaderQos) - Set required policy fields
- Pass that QoS object when constructing the writer or reader
Writer QoS Example
#include <astutedds/dcps/CorePolicy.hpp>
#include <astutedds/dcps/dcps.hpp>
#include <astutedds/dcps/qos.hpp>
dds::domain::DomainParticipant participant(0, 0);
dds::topic::Topic<Demo::HelloWorld> topic(participant, "HelloWorldTopic");
dds::pub::Publisher publisher(participant);
astutedds::dcps::DataWriterQos wqos{};
wqos.reliability.kind =
astutedds::dcps::ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS;
wqos.durability.kind =
astutedds::dcps::DurabilityQosPolicyKind::TRANSIENT_LOCAL_DURABILITY_QOS;
wqos.history.kind =
astutedds::dcps::HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
wqos.history.depth = 10;
dds::pub::DataWriter<Demo::HelloWorld> writer(publisher, topic, wqos);
Matching Reader QoS Example
Reader and writer QoS must be compatible. For first applications, start with the same reliability policy on both sides.
dds::domain::DomainParticipant participant(0, 0);
dds::topic::Topic<Demo::HelloWorld> topic(participant, "HelloWorldTopic");
dds::sub::Subscriber subscriber(participant);
astutedds::dcps::DataReaderQos rqos{};
rqos.reliability.kind =
astutedds::dcps::ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS;
rqos.history.kind =
astutedds::dcps::HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
rqos.history.depth = 10;
dds::sub::DataReader<Demo::HelloWorld> reader(subscriber, topic, rqos);
Builder API Example
If you prefer fluent QoS configuration, use the builder API.
auto writer_qos = astutedds::dcps::DataWriterQosBuilder()
.reliability(
astutedds::dcps::ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS)
.durability(
astutedds::dcps::DurabilityQosPolicyKind::TRANSIENT_LOCAL_DURABILITY_QOS)
.history(astutedds::dcps::HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS, 10)
.build();
dds::pub::DataWriter<Demo::HelloWorld> writer(publisher, topic, writer_qos);
Minimal Policy Variants
Use these quick patterns when changing behavior:
// Lower latency, may drop samples
wqos.reliability.kind =
astutedds::dcps::ReliabilityQosPolicyKind::BEST_EFFORT_RELIABILITY_QOS;
// Late joiners do not receive historical data
wqos.durability.kind =
astutedds::dcps::DurabilityQosPolicyKind::VOLATILE_DURABILITY_QOS;
// Keep only latest sample
wqos.history.kind =
astutedds::dcps::HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
wqos.history.depth = 1;
Next Step
Apply these concepts in code with practical examples in Using QoS Policies, then review the full DDS QoS reference in Quality of Service (QoS).