Class DeliveryPolicy
Encapsulates the options for message delivery behavior.
Namespace: Microsoft.Psi
Assembly: Microsoft.Psi.dll
Syntax
public class DeliveryPolicy : object
Properties
View SourceAttemptSynchronousDelivery
Gets a value indicating whether the runtime should attempt synchronous delivery when possible.
Declaration
public bool AttemptSynchronousDelivery { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
InitialQueueSize
Gets the initial size of the receiver queue that holds the messages pending delivery.
Declaration
public int InitialQueueSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
LatestMessage
Gets a lossy delivery policy which limits the receiver queue to one message, with no latency constraints.
Declaration
public static DeliveryPolicy LatestMessage { get; }
Property Value
Type | Description |
---|---|
DeliveryPolicy |
MaximumLatency
Gets the maximum latency of items to be delivered. Items with a latency larger than this are discarded.
Declaration
public TimeSpan? MaximumLatency { get; }
Property Value
Type | Description |
---|---|
System.Nullable<TimeSpan> |
MaximumQueueSize
Gets the maximum size of the receiver queue that holds the messages pending delivery.
Declaration
public int MaximumQueueSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Name
Gets name used for debugging and diagnostics.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
String |
SynchronousOrThrottle
Gets a delivery policy which attempts synchronous message delivery; if synchronous delivery fails, the source is throttled.
Declaration
public static DeliveryPolicy SynchronousOrThrottle { get; }
Property Value
Type | Description |
---|---|
DeliveryPolicy |
Throttle
Gets a throttling delivery policy, which attempts to throttle its source as long as there is a message in the queue waiting to be processed.
Declaration
public static DeliveryPolicy Throttle { get; }
Property Value
Type | Description |
---|---|
DeliveryPolicy |
ThrottleQueueSize
Gets the number of messages in the receiver queue at and above which the upstream producer will be blocked.
Declaration
public int? ThrottleQueueSize { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Remarks
Use with care, as it affects all other subscribers to the same producer and can introduce deadlocks (a blocked producer cannot process control messages anymore).
Unlimited
Gets a lossless, unlimited delivery policy which lets the receiver queue grow as much as needed, with no latency constraints.
Declaration
public static DeliveryPolicy Unlimited { get; }
Property Value
Type | Description |
---|---|
DeliveryPolicy |
Methods
View SourceLatencyConstrained(TimeSpan)
Creates a latency-constrained delivery policy. Messages older than the specified maximum latency are discarded.
Declaration
public static DeliveryPolicy LatencyConstrained(TimeSpan maximumLatency)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | maximumLatency | The maximum latency for messages to be delivered. |
Returns
Type | Description |
---|---|
DeliveryPolicy | A latency-constrained delivery policy. |
QueueSizeConstrained(Int32, Boolean, Boolean)
Creates a queue-size constrained delivery policy. Messages will accumulate only up to the specified maximum queue size, after which they will be discarded.
Declaration
public static DeliveryPolicy QueueSizeConstrained(int maximumQueueSize, bool throttleWhenFull = false, bool attemptSynchronous = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maximumQueueSize | The maximum queue size. |
System.Boolean | throttleWhenFull | A value indicating whether to block the upstream producer if the receiver queue is full. |
System.Boolean | attemptSynchronous | A value indicating whether to attempt synchronous delivery. |
Returns
Type | Description |
---|---|
DeliveryPolicy | A queue-size constrained delivery policy. |
QueueSizeThrottled(Int32)
Creates a queue-size throttled delivery policy. Messages will accumulate only up to the specified maximum queue size, after which the upstream producer will be blocked until the number of messages in the queue falls below this value.
Declaration
public static DeliveryPolicy QueueSizeThrottled(int throttleQueueSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | throttleQueueSize | A value indicating whether to block the upstream producer if the receiver queue is full. |
Returns
Type | Description |
---|---|
DeliveryPolicy | A queue-size throttled delivery policy. |
WithGuarantees<T>(Func<T, Boolean>)
Creates a typed delivery policy with guarantees by adding a message guaranteed function to an existing untyped delivery policy.
Declaration
public DeliveryPolicy<T> WithGuarantees<T>(Func<T, bool> guaranteeDelivery)
Parameters
Type | Name | Description |
---|---|---|
Func<T, System.Boolean> | guaranteeDelivery | A function that evaluates whether the delivery of a given message should be guaranteed. |
Returns
Type | Description |
---|---|
DeliveryPolicy<T> | The typed delivery policy with guarantees. |
Type Parameters
Name | Description |
---|---|
T | The type of the messages in the resulting delivery policy. |
WithGuarantees<T>(DeliveryPolicy, Func<T, Boolean>)
Creates a typed delivery policy with guarantees by adding a message guaranteed function to an existing untyped delivery policy.
Declaration
public static DeliveryPolicy<T> WithGuarantees<T>(DeliveryPolicy deliveryPolicy, Func<T, bool> guaranteeDelivery)
Parameters
Type | Name | Description |
---|---|---|
DeliveryPolicy | deliveryPolicy | The untyped delivery policy. |
Func<T, System.Boolean> | guaranteeDelivery | A function that evaluates whether the delivery of a given message should be guaranteed. |
Returns
Type | Description |
---|---|
DeliveryPolicy<T> | The typed delivery policy with guarantees. |
Type Parameters
Name | Description |
---|---|
T | The type of the messages in the resulting delivery policy. |
Operators
View SourceImplicit(DeliveryPolicySpec to DeliveryPolicy)
Implicit cast operator from DeliveryPolicySpec to DeliveryPolicy.
Declaration
public static implicit operator DeliveryPolicy(DeliveryPolicySpec deliveryPolicySpec)
Parameters
Type | Name | Description |
---|---|---|
DeliveryPolicySpec | deliveryPolicySpec | The delivery policy specification. |
Returns
Type | Description |
---|---|
DeliveryPolicy |