Class AwsSqsVisibilityHeartbeatOptions
Configures the in-flight visibility-timeout heartbeat for the wired SQS subscriber.
public sealed class AwsSqsVisibilityHeartbeatOptions
- Inheritance
-
AwsSqsVisibilityHeartbeatOptions
- Inherited Members
- Extension Methods
Remarks
SQS makes a received message visible again (redelivered) once its visibility timeout
elapses while the message is still being processed. A long-running handler can therefore
be redelivered the same message before it finishes. When the heartbeat is enabled, the
subscriber periodically calls ChangeMessageVisibility for the in-flight message,
extending its visibility window for as long as the handler runs (up to MaxExtension).
The heartbeat is opt-in (Enabled defaults to false) so that the default consumer behaviour is unchanged. Handlers should still be idempotent because AWS delivery remains at-least-once.
Properties
Enabled
Gets or sets a value indicating whether the visibility-timeout heartbeat is enabled.
public bool Enabled { get; set; }
Property Value
Interval
Gets or sets the interval between visibility extensions.
public TimeSpan Interval { get; set; }
Property Value
- TimeSpan
The heartbeat interval. Default is 30 seconds.
Remarks
Choose an interval shorter than VisibilityTimeout so the extension is applied before the current window expires.
MaxExtension
Gets or sets the maximum total time the heartbeat keeps a single message in-flight.
public TimeSpan MaxExtension { get; set; }
Property Value
- TimeSpan
The maximum cumulative extension per message. Default is 10 minutes.
Remarks
Once this budget is exhausted the subscriber stops extending visibility and the message is allowed to become visible again, providing a safety bound against a stuck handler.
VisibilityTimeout
Gets or sets the visibility timeout applied on each extension.
public TimeSpan VisibilityTimeout { get; set; }
Property Value
- TimeSpan
The visibility window requested per heartbeat. Default is 60 seconds.
Remarks
AWS SQS allows a visibility timeout between 0 seconds and 12 hours.
Methods
Validate()
Validates the heartbeat configuration, enforcing the cross-property invariant that the extension Interval is shorter than the VisibilityTimeout (otherwise the window can lapse — and the same message be redelivered — before the next extension is applied). Only enforced when Enabled is true, since a disabled heartbeat never runs.
public void Validate()
Exceptions
- InvalidOperationException
Thrown when any constraint is violated.