When an OPC UA MonitoredItem queue fills, discardOldest decides which edge of the history is sacrificed. With discardOldest set to true, the server deletes the oldest queued notification and accepts the new one. With it set to false, the server replaces the newest queued entry with the arriving notification. Both policies lose data, but they preserve different evidence for a robotics client.
That difference matters for bursty signals. A latest-state display often prefers recent samples. A forensic trace may value the first values in a transition. A client that requests a queue without choosing the loss policy deliberately can receive a sequence that is technically valid yet unsuitable for its analysis.
## The two overflow paths
OPC UA Part 4 defines the monitored-item queue as a first-in, first-out buffer when queueSize is greater than one. If the queue is full and a new notification arrives, the configured discard policy applies.
With discardOldest true, the oldest notification is removed, remaining entries shift toward the front, and the new notification is appended. The queue stays biased toward the most recent history. If values 10, 20, and 30 are queued and 40 arrives, the surviving sequence is 20, 30, 40.
With discardOldest false, the server replaces the last value added to the queue with the new value. The older prefix remains. Starting from 10, 20, 30, an arriving 40 leaves 10, 20, 40. This preserves the beginning of the backlog while ensuring the newest arrival is represented.
The second behavior is sometimes mistaken for rejecting the arriving value. It does not simply keep 10, 20, 30. The newest queued value is replaced by 40, so the client sees a gap between the preserved prefix and the current edge.
## Overflow evidence moves with the policy
For DataValues in a queue larger than one, the server sets the Overflow InfoBit in a surviving notification to indicate that values were lost. The placement depends on discardOldest.
When discardOldest is true, the next value in the queue gets the Overflow bit after the oldest value is deleted. In the 10, 20, 30 plus 40 example, 20 carries evidence that something before it was removed.
When discardOldest is false, the new value that replaces the last entry gets the bit. In the surviving 10, 20, 40 sequence, 40 indicates that values before this newest edge were not all retained.
Clients should inspect the complete StatusCode, including InfoBits, rather than only Good, Uncertain, or Bad severity. A value can have Good severity while also carrying overflow evidence. Quality and history completeness are separate conclusions.
## Queue size one is a special case
Part 4 treats queueSize 1 as a latest-value buffer. It always contains the newest notification, and discardOldest is ignored. The client gets the most up-to-date retained value when sampling is faster than publishing, but the normal queue-overflow bit behavior for larger queues does not provide a count of all overwritten samples.
A queue of one is efficient for dashboards that need current state and do not need every transition. It is a poor substitute for an audit trail, vibration waveform, or short pulse capture. Fast sampling cannot recover history that the buffer is configured to overwrite.
## Choose policy from the consuming question
A robot-cell overview usually wants the most recent position, temperature, or mode. A queue biased toward recent data, or a queue of one, can minimize displayed age. The design must still handle missed intermediate alarms or state transitions separately.
A transition analyzer may need the earliest samples that explain how a fault began. discardOldest false preserves the older prefix, but it still loses values near the newest edge when overflow continues. If complete history is required, neither discard policy is sufficient; the queue, publication rate, and downstream storage must be sized to avoid overflow under the credible burst.
For discrete states, losing one value can hide a brief state entirely. Suppose a gripper reports OPEN, CLOSING, CLOSED, FAULT during network delay. A three-entry queue with discardOldest true ends with CLOSING, CLOSED, FAULT. With false it may end with OPEN, CLOSING, FAULT. Each sequence supports a different, incomplete narrative. The Overflow bit is the signal not to infer an unbroken transition.
## Size for delayed delivery, not nominal timing
A nominal sampling-to-publishing ratio provides a minimum estimate. A 10 ms notification rate and 100 ms publishing interval can generate ten notifications per cycle. But delayed Publish requests, network latency, maxNotificationsPerPublish, server scheduling, and filtering bursts can extend the retention window.
Use the revisedQueueSize returned by the server, because it may be smaller than requested. Test under the longest credible absence of successful publication. If overflow occurs, measure which values survive and confirm the InfoBit is handled by the client library rather than stripped during conversion.
Sequence numbers on NotificationMessages detect message-level gaps and support retransmission behavior. They do not enumerate samples removed inside a MonitoredItem queue before a message was created. Application sequence numbers embedded by the producer can provide stronger evidence when every generated sample matters.
## Handle overflow as a data-quality event
On receiving Overflow, mark the affected interval incomplete. Preserve the notification that carries the bit, its SourceTimestamp, server and client receive times, queue configuration, and Subscription sequence number. Do not interpolate discrete robot states across the gap unless the application has an explicit, validated model for doing so.
Expose overflow counters in diagnostics. Repeated events can indicate an undersized queue, slow publishing, missing Publish requests, an unexpectedly permissive filter, or an upstream burst. The remedy depends on the cause; increasing queue size alone can add latency and memory use without fixing delivery.
Tests should cover both policies with a known queue and more generated values than capacity. Verify exact survivors, Overflow placement, queueSize 1 behavior, and recovery after publishing resumes. Include arrays and status-only changes if the application uses them.
DiscardOldest is not a minor buffer preference. It chooses which part of a robot signal's recent history remains after capacity is exhausted. OPC UA provides an Overflow bit so clients know the sequence is incomplete. A dependable integration selects the policy from the consumer's evidence needs, sizes the path to avoid routine loss, and treats every overflow as a gap rather than a continuous record.