Table of Contents

Class MqttConsumer

Namespace
Silverback.Messaging.Broker
Assembly
Silverback.Integration.MQTT.dll

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

public class MqttConsumer : Consumer<MqttMessageIdentifier>, IConsumer, IDisposable
Inheritance
MqttConsumer
Implements
Inherited Members

Constructors

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

Initializes a new instance of the MqttConsumer class.

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

Parameters

name string

The consumer identifier.

client IMqttClientWrapper

The IMqttClientWrapper.

configuration MqttClientConfiguration

The MqttClientConfiguration with only the consumer endpoints.

behaviorsProvider IBrokerBehaviorsProvider<IConsumerBehavior>

The IBrokerBehaviorsProvider<TBehavior>.

serviceProvider IServiceProvider

The IServiceProvider to be used to resolve the necessary services.

logger ISilverbackLogger<MqttConsumer>

The ISilverbackLogger<TCategoryName>.

Properties

Client

Gets the related IBrokerClient.

public IMqttClientWrapper Client { get; }

Property Value

IMqttClientWrapper

Configuration

Gets the client configuration.

public MqttClientConfiguration Configuration { get; }

Property Value

MqttClientConfiguration

EndpointsConfiguration

Gets the endpoints configuration.

public IReadOnlyCollection<MqttConsumerEndpointConfiguration> EndpointsConfiguration { get; }

Property Value

IReadOnlyCollection<MqttConsumerEndpointConfiguration>

Methods

CommitCoreAsync(IReadOnlyCollection<MqttMessageIdentifier>)

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

protected override ValueTask CommitCoreAsync(IReadOnlyCollection<MqttMessageIdentifier> brokerMessageIdentifiers)

Parameters

brokerMessageIdentifiers IReadOnlyCollection<MqttMessageIdentifier>

The identifiers of to message be committed.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

Dispose(bool)

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

protected override void Dispose(bool disposing)

Parameters

disposing bool

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

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.

protected override ValueTask RollbackCoreAsync(IReadOnlyCollection<MqttMessageIdentifier> brokerMessageIdentifiers)

Parameters

brokerMessageIdentifiers IReadOnlyCollection<MqttMessageIdentifier>

The identifiers of to message be rolled back.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

StartCoreAsync()

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

protected override ValueTask StartCoreAsync()

Returns

ValueTask

A ValueTask representing the asynchronous operation.

StopCoreAsync()

Stops consuming while staying connected to the message broker.

protected override ValueTask StopCoreAsync()

Returns

ValueTask

A ValueTask representing the asynchronous operation.

WaitUntilConsumingStoppedCoreAsync()

Waits until the consuming is stopped.

protected override ValueTask WaitUntilConsumingStoppedCoreAsync()

Returns

ValueTask

A ValueTask representing the asynchronous operation.