Class MqttConsumer
Consumes from one or more endpoints and pushes the received messages via the message bus.
Inherited Members
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 | |
| IServiceProvider | serviceProvider | The IServiceProvider to be used to resolve the necessary services. |
| ISilverbackLogger<MqttConsumer> | logger |
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
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 |
Overrides
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
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
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
WaitUntilConsumingStoppedCoreAsync()
Waits until the consuming is stopped.
Declaration
protected override ValueTask WaitUntilConsumingStoppedCoreAsync()
Returns
| Type | Description |
|---|---|
| ValueTask | A ValueTask representing the asynchronous operation. |