Show / Hide Table of Contents

    Interface IConsumer

    Consumes from one or more endpoints and pushes the received messages via the message bus.

    Namespace: Silverback.Messaging.Broker
    Assembly: Silverback.Integration.dll
    Syntax
    public interface IConsumer

    Properties

    Client

    Gets the related IBrokerClient.

    Declaration
    IBrokerClient Client { get; }
    Property Value
    Type Description
    IBrokerClient

    DisplayName

    Gets the name to be displayed in the human-targeted output (e.g. logs, health checks result, etc.).

    Declaration
    string DisplayName { get; }
    Property Value
    Type Description
    string

    EndpointsConfiguration

    Gets the endpoints configuration.

    Declaration
    IReadOnlyCollection<ConsumerEndpointConfiguration> EndpointsConfiguration { get; }
    Property Value
    Type Description
    IReadOnlyCollection<ConsumerEndpointConfiguration>

    Name

    Gets the consumer name.

    Declaration
    string Name { get; }
    Property Value
    Type Description
    string

    StatusInfo

    Gets the IConsumerStatusInfo containing the status details and basic statistics of this consumer.

    Declaration
    IConsumerStatusInfo StatusInfo { get; }
    Property Value
    Type Description
    IConsumerStatusInfo

    Methods

    CommitAsync(IBrokerMessageIdentifier)

    Confirms that the specified message has been successfully processed. The acknowledgement will be sent to the message broker and the message will never be consumed again (by the same logical consumer / consumer group).
    Declaration
    ValueTask CommitAsync(IBrokerMessageIdentifier brokerMessageIdentifier)
    Parameters
    Type Name Description
    IBrokerMessageIdentifier brokerMessageIdentifier

    The identifier of the message to be committed.

    Returns
    Type Description
    ValueTask

    A Task representing the asynchronous operation.

    CommitAsync(IReadOnlyCollection<IBrokerMessageIdentifier>)

    Confirms that the specified messages have been successfully processed. The acknowledgement will be sent to the message broker, and the message will never be consumed again (by the same logical consumer / consumer group).
    Declaration
    ValueTask CommitAsync(IReadOnlyCollection<IBrokerMessageIdentifier> brokerMessageIdentifiers)
    Parameters
    Type Name Description
    IReadOnlyCollection<IBrokerMessageIdentifier> brokerMessageIdentifiers

    The identifiers of to message be committed.

    Returns
    Type Description
    ValueTask

    A Task representing the asynchronous operation.

    IncrementFailedAttempts(IRawInboundEnvelope)

    Increments the stored failed attempts count for the specified envelope.

    Declaration
    int IncrementFailedAttempts(IRawInboundEnvelope envelope)
    Parameters
    Type Name Description
    IRawInboundEnvelope envelope

    The envelope.

    Returns
    Type Description
    int

    The current failed attempts count after the increment.

    RollbackAsync(IBrokerMessageIdentifier)

    Notifies that an error occurred while processing the specified message. If necessary, the information will be sent to the message broker to ensure that the message will be consumed again.
    Declaration
    ValueTask RollbackAsync(IBrokerMessageIdentifier brokerMessageIdentifier)
    Parameters
    Type Name Description
    IBrokerMessageIdentifier brokerMessageIdentifier

    The identifier of the message to be rolled back.

    Returns
    Type Description
    ValueTask

    A Task representing the asynchronous operation.

    RollbackAsync(IReadOnlyCollection<IBrokerMessageIdentifier>)

    Notifies that an error occured while processing the specified messages. If necessary the information will be sent to the message broker to ensure that the message will be re-processed.
    Declaration
    ValueTask RollbackAsync(IReadOnlyCollection<IBrokerMessageIdentifier> brokerMessageIdentifiers)
    Parameters
    Type Name Description
    IReadOnlyCollection<IBrokerMessageIdentifier> brokerMessageIdentifiers

    The identifiers of to messages be rolled back.

    Returns
    Type Description
    ValueTask

    A Task representing the asynchronous operation.

    StartAsync()

    Starts consuming. Used after StopAsync(bool) has been called to resume consuming.

    Declaration
    ValueTask StartAsync()
    Returns
    Type Description
    ValueTask

    A Task representing the asynchronous operation.

    StopAsync(bool)

    Stops the consumer without disconnecting. Can be used to pause and resume consuming.

    Declaration
    ValueTask StopAsync(bool waitUntilStopped = true)
    Parameters
    Type Name Description
    bool waitUntilStopped

    A value indicating whether the method should wait until the consumer has been effectively stopped.

    Returns
    Type Description
    ValueTask

    A Task representing the asynchronous operation. This Task will complete as soon as the stopping signal has been sent.

    TriggerReconnectAsync()

    Stops the consumer and starts an asynchronous Task to disconnect and reconnect it.

    Declaration
    ValueTask TriggerReconnectAsync()
    Returns
    Type Description
    ValueTask

    A Task representing the asynchronous operation. This Task will complete as soon as the stopping signal has been sent, while the process will be completed in another asynchronous Task.

    Remarks

    This is used to recover when the consumer is stuck in state where it's not able to rollback or commit anymore.

    GitHub E-Mail
    ↑ Back to top © 2026 Sergio Aquilini