Table of Contents

Class MessageAsyncEnumerableOptions<T>

Namespace
Savvyio.Messaging
Assembly
Savvyio.Messaging.dll

Configuration options that is related to IAcknowledgeable messages.

public class MessageAsyncEnumerableOptions<T> : IValidatableParameterObject, IParameterObject where T : IRequest

Type Parameters

T

The type of the payload constraint to the IRequest interface.

Inheritance
MessageAsyncEnumerableOptions<T>
Implements

Examples

This example shows how to configure callbacks that observe each streamed message and the properties acknowledged at the end of the sequence.

using System.Collections.Generic;
using System.Threading.Tasks;
using Savvyio;
using Savvyio.Messaging;

namespace ExampleApp;

public sealed class MessageAsyncEnumerableOptionsExample
{
    public MessageAsyncEnumerableOptions<CreateOrderCommand> Configure()
    {
        var options = new MessageAsyncEnumerableOptions<CreateOrderCommand>
        {
            MessageCallback = async message => await message.AcknowledgeAsync().ConfigureAwait(false),
            AcknowledgedPropertiesCallback = async acknowledged => await Task.CompletedTask.ConfigureAwait(false)
        };
        options.ValidateOptions();
        return options;
    }
}

public sealed record CreateOrderCommand(string OrderId) : Request;

Constructors

MessageAsyncEnumerableOptions()

Initializes a new instance of the MessageAsyncEnumerableOptions<T> class.

public MessageAsyncEnumerableOptions()

Remarks

The following table shows the initial property values for an instance of MessageAsyncEnumerableOptions<T>.

PropertyInitial Value
AcknowledgedPropertiesnew ConcurrentBag<IDictionary<string, object>>()
AcknowledgedPropertiesCallbacknull
MessageCallbacknull

Properties

AcknowledgedProperties

Gets or sets the implementation of an IProducerConsumerCollection<T> that is used to store all acknowledged properties. Default is a new instance of ConcurrentBag<T>.

public IProducerConsumerCollection<IDictionary<string, object>> AcknowledgedProperties { get; set; }

Property Value

IProducerConsumerCollection<IDictionary<string, object>>

The implementation of an IProducerConsumerCollection<T> that is used to store all acknowledged properties.

AcknowledgedPropertiesCallback

Gets or sets the delegate that is invoked at the end of a sequence with all acknowledged properties.

public Func<IEnumerable<IDictionary<string, object>>, Task> AcknowledgedPropertiesCallback { get; set; }

Property Value

Func<IEnumerable<IDictionary<string, object>>, Task>

The delegate that is invoked at the end of a sequence with all acknowledged properties.

MessageCallback

Gets or sets the delegate that is invoked once for each message fetched from a source.

public Func<IMessage<T>, Task> MessageCallback { get; set; }

Property Value

Func<IMessage<T>, Task>

The delegate that is invoked once for each message fetched from a source.

Methods

ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

public void ValidateOptions()

Remarks

This method is expected to throw exceptions when one or more conditions fails to be in a valid state.