Show / Hide Table of Contents

    Class MqttConsumer

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

    Inheritance
    object
    Consumer<MqttMessageIdentifier>
    MqttConsumer
    Implements
    IConsumer
    IDisposable
    Inherited Members
    Consumer<MqttMessageIdentifier>.TriggerReconnectAsync()
    Consumer<MqttMessageIdentifier>.StartAsync()
    Consumer<MqttMessageIdentifier>.StopAsync(bool)
    Consumer<MqttMessageIdentifier>.CommitAsync(IBrokerMessageIdentifier)
    Consumer<MqttMessageIdentifier>.CommitAsync(IReadOnlyCollection<IBrokerMessageIdentifier>)
    Consumer<MqttMessageIdentifier>.RollbackAsync(IBrokerMessageIdentifier)
    Consumer<MqttMessageIdentifier>.RollbackAsync(IReadOnlyCollection<IBrokerMessageIdentifier>)
    Consumer<MqttMessageIdentifier>.IncrementFailedAttempts(IRawInboundEnvelope)
    Consumer<MqttMessageIdentifier>.Dispose()
    Consumer<MqttMessageIdentifier>.HandleMessageAsync(byte[], IReadOnlyCollection<MessageHeader>, ConsumerEndpoint, IBrokerMessageIdentifier, ISequenceStore)
    Consumer<MqttMessageIdentifier>.SetConnectedStatus()
    Consumer<MqttMessageIdentifier>.RevertConnectedStatus()
    Consumer<MqttMessageIdentifier>.IsStartedAndNotStopping()
    Consumer<MqttMessageIdentifier>.Name
    Consumer<MqttMessageIdentifier>.DisplayName
    Consumer<MqttMessageIdentifier>.StatusInfo
    Consumer<MqttMessageIdentifier>.ServiceProvider
    Consumer<MqttMessageIdentifier>.IsStarting
    Consumer<MqttMessageIdentifier>.IsStarted
    Consumer<MqttMessageIdentifier>.IsStopping
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: Silverback.Messaging.Broker
    Assembly: Silverback.Integration.MQTT.dll
    Syntax
    public class MqttConsumer : Consumer<MqttMessageIdentifier>, IConsumer, IDisposable

    Constructors

    MqttConsumer(string, IMqttClientWrapper, MqttClientConfiguration, IBrokerBehaviorsProvider<IConsumerBehavior>, IServiceProvider, ISilverbackLogger<MqttConsumer>)

    Initializes a new instance of the MqttConsumer class.

    Declaration
    public MqttConsumer(string name, IMqttClientWrapper client, MqttClientConfiguration configuration, IBrokerBehaviorsProvider<IConsumerBehavior> behaviorsProvider, IServiceProvider serviceProvider, ISilverbackLogger<MqttConsumer> logger)
    Parameters
    Type Name Description
    string name

    The consumer identifier.

    IMqttClientWrapper client

    The IMqttClientWrapper.

    MqttClientConfiguration configuration

    The MqttClientConfiguration with only the consumer endpoints.

    IBrokerBehaviorsProvider<IConsumerBehavior> behaviorsProvider

    The IBrokerBehaviorsProvider<TBehavior>.

    IServiceProvider serviceProvider

    The IServiceProvider to be used to resolve the necessary services.

    ISilverbackLogger<MqttConsumer> logger

    The ISilverbackLogger<TCategoryName>.

    Properties

    Client

    Gets the related IBrokerClient.

    Declaration
    public IMqttClientWrapper Client { get; }
    Property Value
    Type Description
    IMqttClientWrapper

    Configuration

    Gets the client configuration.

    Declaration
    public MqttClientConfiguration Configuration { get; }
    Property Value
    Type Description
    MqttClientConfiguration

    EndpointsConfiguration

    Gets the endpoints configuration.

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

    Methods

    CommitCoreAsync(IReadOnlyCollection<MqttMessageIdentifier>)

    Commits the specified messages sending the acknowledgement to the message broker.

    Declaration
    protected override ValueTask CommitCoreAsync(IReadOnlyCollection<MqttMessageIdentifier> brokerMessageIdentifiers)
    Parameters
    Type Name Description
    IReadOnlyCollection<MqttMessageIdentifier> brokerMessageIdentifiers

    The identifiers of to message be committed.

    Returns
    Type Description
    ValueTask

    A ValueTask representing the asynchronous operation.

    Overrides
    Consumer<MqttMessageIdentifier>.CommitCoreAsync(IReadOnlyCollection<MqttMessageIdentifier>)

    Dispose(bool)

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    A value indicating whether the method has been called by the Dispose method and not from the finalizer.

    Overrides
    Consumer<MqttMessageIdentifier>.Dispose(bool)

    RollbackCoreAsync(IReadOnlyCollection<MqttMessageIdentifier>)

    If necessary, notifies the message broker that the specified messages couldn't be processed successfully, to ensure that they will be consumed again.

    Declaration
    protected override ValueTask RollbackCoreAsync(IReadOnlyCollection<MqttMessageIdentifier> brokerMessageIdentifiers)
    Parameters
    Type Name Description
    IReadOnlyCollection<MqttMessageIdentifier> brokerMessageIdentifiers

    The identifiers of to message be rolled back.

    Returns
    Type Description
    ValueTask

    A ValueTask representing the asynchronous operation.

    Overrides
    Consumer<MqttMessageIdentifier>.RollbackCoreAsync(IReadOnlyCollection<MqttMessageIdentifier>)

    StartCoreAsync()

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

    Declaration
    protected override ValueTask StartCoreAsync()
    Returns
    Type Description
    ValueTask

    A ValueTask representing the asynchronous operation.

    Overrides
    Consumer<MqttMessageIdentifier>.StartCoreAsync()

    StopCoreAsync()

    Stops consuming while staying connected to the message broker.

    Declaration
    protected override ValueTask StopCoreAsync()
    Returns
    Type Description
    ValueTask

    A ValueTask representing the asynchronous operation.

    Overrides
    Consumer<MqttMessageIdentifier>.StopCoreAsync()

    WaitUntilConsumingStoppedCoreAsync()

    Waits until the consuming is stopped.

    Declaration
    protected override ValueTask WaitUntilConsumingStoppedCoreAsync()
    Returns
    Type Description
    ValueTask

    A ValueTask representing the asynchronous operation.

    Overrides
    Consumer<MqttMessageIdentifier>.WaitUntilConsumingStoppedCoreAsync()

    Implements

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