Table of Contents

Struct MessageBrokerListenerOptions

Namespace
LfrlAnvil.MessageBroker.Client
Assembly
LfrlAnvil.MessageBroker.Client.dll

Represents available MessageBrokerListener options during its binding.

public readonly struct MessageBrokerListenerOptions
Inherited Members

Fields

DefaultPrefetchHint

Default PrefetchHint. Equal to 1.

public const short DefaultPrefetchHint = 1

Field Value

short

Properties

AreAcksEnabled

Specifies whether the client is expected to send ACK or negative ACK to the server in order to confirm message notification.

public bool AreAcksEnabled { get; }

Property Value

bool

Remarks

This will always be enabled when MaxRetries or MaxRedeliveries or DeadLetterCapacityHint is greater than 0.

DeadLetterCapacityHint

Specifies how many messages will be stored at most by the dead letter.

public int DeadLetterCapacityHint { get; }

Property Value

int

Remarks

This is a min value. Actual value is dependent on all listeners attached to the queue and the state of the queue's dead letter.

Default

Represents default options, with default prefetch hint, disabled retries and redeliveries and dead letter, lack of filter expression, and enabled ACKs.

public static MessageBrokerListenerOptions Default { get; }

Property Value

MessageBrokerListenerOptions

DefaultMinAckTimeout

Default MinAckTimeout. Equal to 10 minutes.

public static Duration DefaultMinAckTimeout { get; }

Property Value

Duration

DefaultRetryDelay

Default RetryDelay. Equal to 30 seconds.

public static Duration DefaultRetryDelay { get; }

Property Value

Duration

FilterExpression

Specifies server-side message filter expression.

public string? FilterExpression { get; }

Property Value

string

MaxRedeliveries

Specifies how many times the server will attempt to automatically send a message notification redelivery when the client fails to respond with either an ACK or a negative ACK in time (see MinAckTimeout), before giving up.

public int MaxRedeliveries { get; }

Property Value

int

Remarks

Redelivery will be disabled when value is equal 0.

MaxRetries

Specifies how many times the server will attempt to automatically send a message notification retry when the client responds with a negative ACK, before giving up.

public int MaxRetries { get; }

Property Value

int

Remarks

Retries will be disabled when value is equal 0.

MinAckTimeout

Specifies the minimum amount of time that the server will wait for the client to send either an ACK or a negative ACK before attempting a message notification redelivery. Actual ACK timeout may be different due to the state of the queue and other listeners bound to it.

public Duration MinAckTimeout { get; }

Property Value

Duration

Remarks

Equal to Zero when AreAcksEnabled is equal to false.

MinDeadLetterRetention

Specifies the retention period for messages stored in the dead letter.

public Duration MinDeadLetterRetention { get; }

Property Value

Duration

Remarks

This is a min value. Actual value is dependent on all listeners attached to the queue and the state of the queue's dead letter.

PrefetchHint

Specifies how many messages intended for the created listener can be sent by the server to the client at the same time.

public short PrefetchHint { get; }

Property Value

short

Remarks

This is a max potential value. Actual value is dependent on all listeners attached to the queue and all of its currently pending messages.

RetryDelay

Specifies the delay between the server successfully processing negative ACK sent by the client and the server sending a message notification retry.

public Duration RetryDelay { get; }

Property Value

Duration

Remarks

Equal to Zero when MaxRetries is equal to 0.

Methods

EnableAcks(bool)

Allows to change AreAcksEnabled.

[Pure]
public MessageBrokerListenerOptions EnableAcks(bool enabled = true)

Parameters

enabled bool

New AreAcksEnabled value. Value will be ignored when MaxRetries or MaxRedeliveries or DeadLetterCapacityHint is greater than 0. Equal to true by default.

Returns

MessageBrokerListenerOptions

New MessageBrokerListenerOptions instance.

SetDeadLetterPolicy(int, Duration)

[Pure]
public MessageBrokerListenerOptions SetDeadLetterPolicy(int capacityHint, Duration minRetention)

Parameters

capacityHint int

New DeadLetterCapacityHint value.

minRetention Duration

New MinDeadLetterRetention value. Sub-millisecond components will be trimmed. Value will be ignored when DeadLetterCapacityHint is equal to 0.

Returns

MessageBrokerListenerOptions

New MessageBrokerListenerOptions instance.

Exceptions

ArgumentOutOfRangeException

When capacityHint is less than 0 or when capacityHint is greater than 0 and minRetention is less than 1 ms or when capacityHint is equal to 0 and minRetention is less than 0.

SetFilterExpression(string?)

Allows to change FilterExpression.

[Pure]
public MessageBrokerListenerOptions SetFilterExpression(string? value)

Parameters

value string

New FilterExpression value.

Returns

MessageBrokerListenerOptions

New MessageBrokerListenerOptions instance.

Exceptions

ArgumentException

When value is not null and consists only of white-space characters.

SetMaxRedeliveries(int)

Allows to change MaxRedeliveries.

[Pure]
public MessageBrokerListenerOptions SetMaxRedeliveries(int value)

Parameters

value int

New MaxRedeliveries value.

Returns

MessageBrokerListenerOptions

New MessageBrokerListenerOptions instance.

Exceptions

ArgumentOutOfRangeException

When value is less than 0.

SetMinAckTimeout(Duration?)

Allows to change MinAckTimeout.

[Pure]
public MessageBrokerListenerOptions SetMinAckTimeout(Duration? value)

Parameters

value Duration?

New explicit MinAckTimeout value. Sub-millisecond components will be trimmed. Value will be ignored when AreAcksEnabled is equal to false.

Returns

MessageBrokerListenerOptions

New MessageBrokerListenerOptions instance.

Exceptions

ArgumentOutOfRangeException

When value is not null and is not in [1 ms, 2147483647 ms] range.

SetPrefetchHint(short?)

Allows to change PrefetchHint.

[Pure]
public MessageBrokerListenerOptions SetPrefetchHint(short? value)

Parameters

value short?

New value.

Returns

MessageBrokerListenerOptions

New MessageBrokerListenerOptions instance.

Exceptions

ArgumentOutOfRangeException

When value is not null and is less than 1.

SetRetryPolicy(int, Duration?)

Allows to change MaxRetries and RetryDelay.

[Pure]
public MessageBrokerListenerOptions SetRetryPolicy(int maxRetries, Duration? delay = null)

Parameters

maxRetries int

New MaxRetries value.

delay Duration?

Optional new explicit RetryDelay value. Sub-millisecond components will be trimmed. Value will be ignored when MaxRetries is equal to 0. Equal to null by default.

Returns

MessageBrokerListenerOptions

New MessageBrokerListenerOptions instance.

Exceptions

ArgumentOutOfRangeException

When maxRetries is less than 0 or when delay is not null and is not in [0, 2147483647 ms] range.