DURABILITY
-
The DURABILITY policy controls whether data writers should maintain samples after they have been sent to known subscribers. This policy applies to the topic, data reader, and data writer entities via the
durability
member of their respective QoS structures. Below is the IDL related to the durability QoS policy:
-
-
enum DurabilityQosPolicyKind {
-
VOLATILE_DURABILITY_QOS, // Least Durability
-
TRANSIENT_LOCAL_DURABILITY_QOS,
-
TRANSIENT_DURABILITY_QOS,
-
PERSISTENT_DURABILITY_QOS // Greatest Durability
-
};
-
-
struct DurabilityQosPolicy {
-
DurabilityQosPolicyKind kind;
-
Duration_t service_cleanup_delay;
-
};
-
-
By default the
kind
is
VOLATILE_DURABILITY_QOS
and
service_cleanup_delay
is zero which means infinite time delay.
-
A durability kind of
VOLATILE_DURABILITY_QOS
means samples are discarded after being sent to all known subscribers. As a side effect, subscribers cannot recover samples sent before they connect.
-
A durability kind of
TRANSIENT_LOCAL_DURABILITY_QOS
means that data readers that are associated/connected with a data writer will be sent all of the samples in the data writer’s history.
-
A durability kind of
TRANSIENT_DURABILITY_QOS
means that samples outlive a data writer and last as long as the process is alive. The samples are kept in memory, but are not persisted to permanent storage. A data reader subscribed to the same topic and partition within the same domain will be sent all of the cached samples that belong to the same topic/partition.
-
A durability kind of
PERSISTENT_DURABILITY_QOS
provides basically the same functionality as transient durability except the cached samples are persisted and will survive process destruction.
-
When transient or persistent durability is specified, the
service_cleanup_delay
specifies how long to delay the instance cleanup after the instance is disposed and all data writers unregister the instance.
-
The durability policy is considered during the creation of associations between data writers and data readers. The value of both sides of the association must be compatible in order for an association to be created. The durability kind value of the data writer must be greater than or equal to the corresponding value of the data reader. The durability kind values are ordered as follows:
-
PERSISTENT_DURABILITY_QOS >
-
TRANSIENT_DURABILITY_QOS >
-
TRANSIENT_LOCAL_DURABILITY_QOS >
-
VOLATILE_DURABILITY_QOS
-