Class MqttConsumer
Consumes an endpoint and invokes a callback delegate when a message is received.
Inheritance
Inherited Members
Namespace: Silverback.Messaging.Broker
Assembly: Silverback.Integration.MQTT.dll
Syntax
public class MqttConsumer : Consumer<MqttBroker, MqttConsumerEndpoint, MqttMessageIdentifier>, IConsumer, IDisposable
Constructors
| Improve this doc View sourceMqttConsumer(MqttBroker, MqttConsumerEndpoint, IBrokerBehaviorsProvider<IConsumerBehavior>, IServiceProvider, IInboundLogger<MqttConsumer>)
Initializes a new instance of the MqttConsumer class.
Declaration
public MqttConsumer(MqttBroker broker, MqttConsumerEndpoint endpoint, IBrokerBehaviorsProvider<IConsumerBehavior> behaviorsProvider, IServiceProvider serviceProvider, IInboundLogger<MqttConsumer> logger)
Parameters
Type | Name | Description |
---|---|---|
MqttBroker | broker | The IBroker that is instantiating the consumer. |
MqttConsumerEndpoint | endpoint | The endpoint to be consumed. |
IBrokerBehaviorsProvider<IConsumerBehavior> | behaviorsProvider | |
IServiceProvider | serviceProvider | The IServiceProvider to be used to resolve the needed services. |
IInboundLogger<MqttConsumer> | logger |
Methods
| Improve this doc View sourceCommitCoreAsync(IReadOnlyCollection<MqttMessageIdentifier>)
Commits the specified messages sending the acknowledgement to the message broker.
Declaration
protected override Task CommitCoreAsync(IReadOnlyCollection<MqttMessageIdentifier> brokerMessageIdentifiers)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<MqttMessageIdentifier> | brokerMessageIdentifiers | The identifiers of to message be committed. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Overrides
| Improve this doc View sourceConnectCoreAsync()
Connects to the message broker.
Declaration
protected override Task ConnectCoreAsync()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Overrides
| Improve this doc View sourceDisconnectCoreAsync()
Disconnects from the message broker.
Declaration
protected override Task DisconnectCoreAsync()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Overrides
| Improve this doc View sourceDispose(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
| Improve this doc View sourceGetCurrentSequenceStores()
Gets the ISequenceStore instances used by this consumer. Some brokers will require
multiple stores (e.g. the KafkaConsumer
will create a store per each assigned partition).
Declaration
public override IReadOnlyList<ISequenceStore> GetCurrentSequenceStores()
Returns
Type | Description |
---|---|
IReadOnlyList<ISequenceStore> | The list of ISequenceStore. |
Overrides
Remarks
Used only for testing and maintained to preserve backward compatibility.
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 Task RollbackCoreAsync(IReadOnlyCollection<MqttMessageIdentifier> brokerMessageIdentifiers)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<MqttMessageIdentifier> | brokerMessageIdentifiers | The identifiers of to message be rolled back. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Overrides
| Improve this doc View sourceStartCoreAsync()
Starts consuming. Called to resume consuming after StopAsync() has been called.
Declaration
protected override Task StartCoreAsync()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Overrides
| Improve this doc View sourceStopCoreAsync()
Stops consuming while staying connected to the message broker.
Declaration
protected override Task StopCoreAsync()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Overrides
| Improve this doc View sourceWaitUntilConsumingStoppedCoreAsync()
Waits until the consuming is stopped.
Declaration
protected override Task WaitUntilConsumingStoppedCoreAsync()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |