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
namestringThe consumer identifier.
clientIMqttClientWrapperThe IMqttClientWrapper.
configurationMqttClientConfigurationThe MqttClientConfiguration with only the consumer endpoints.
behaviorsProviderIBrokerBehaviorsProvider<IConsumerBehavior>serviceProviderIServiceProviderThe IServiceProvider to be used to resolve the necessary services.
loggerISilverbackLogger<MqttConsumer>
Properties
Client
Gets the related IBrokerClient.
public IMqttClientWrapper Client { get; }
Property Value
Configuration
Gets the client configuration.
public MqttClientConfiguration Configuration { get; }
Property Value
EndpointsConfiguration
Gets the endpoints configuration.
public IReadOnlyCollection<MqttConsumerEndpointConfiguration> EndpointsConfiguration { get; }
Property Value
Methods
CommitCoreAsync(IReadOnlyCollection<MqttMessageIdentifier>)
Commits the specified messages sending the acknowledgement to the message broker.
protected override ValueTask CommitCoreAsync(IReadOnlyCollection<MqttMessageIdentifier> brokerMessageIdentifiers)
Parameters
brokerMessageIdentifiersIReadOnlyCollection<MqttMessageIdentifier>The identifiers of to message be committed.
Returns
Dispose(bool)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
protected override void Dispose(bool disposing)
Parameters
disposingboolA value indicating whether the method has been called by the
Disposemethod 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
brokerMessageIdentifiersIReadOnlyCollection<MqttMessageIdentifier>The identifiers of to message be rolled back.
Returns
StartCoreAsync()
Starts consuming. Called to resume consuming after StopAsync(bool) has been called.
protected override ValueTask StartCoreAsync()
Returns
StopCoreAsync()
Stops consuming while staying connected to the message broker.
protected override ValueTask StopCoreAsync()
Returns
WaitUntilConsumingStoppedCoreAsync()
Waits until the consuming is stopped.
protected override ValueTask WaitUntilConsumingStoppedCoreAsync()