Interface IConsumer
- Namespace
- Silverback.Messaging.Broker
- Assembly
- Silverback.Integration.dll
Consumes from one or more endpoints and pushes the received messages via the message bus.
public interface IConsumer
Properties
Client
Gets the related IBrokerClient.
IBrokerClient Client { get; }
Property Value
DisplayName
Gets the name to be displayed in the human-targeted output (e.g. logs, health checks result, etc.).
string DisplayName { get; }
Property Value
EndpointsConfiguration
Gets the endpoints configuration.
IReadOnlyCollection<ConsumerEndpointConfiguration> EndpointsConfiguration { get; }
Property Value
Name
Gets the consumer name.
string Name { get; }
Property Value
StatusInfo
Gets the IConsumerStatusInfo containing the status details and basic statistics of this consumer.
IConsumerStatusInfo StatusInfo { get; }
Property Value
Methods
CommitAsync(IBrokerMessageIdentifier)
ValueTask CommitAsync(IBrokerMessageIdentifier brokerMessageIdentifier)
Parameters
brokerMessageIdentifierIBrokerMessageIdentifierThe identifier of the message to be committed.
Returns
CommitAsync(IReadOnlyCollection<IBrokerMessageIdentifier>)
ValueTask CommitAsync(IReadOnlyCollection<IBrokerMessageIdentifier> brokerMessageIdentifiers)
Parameters
brokerMessageIdentifiersIReadOnlyCollection<IBrokerMessageIdentifier>The identifiers of to message be committed.
Returns
IncrementFailedAttempts(IRawInboundEnvelope)
Increments the stored failed attempts count for the specified envelope.
int IncrementFailedAttempts(IRawInboundEnvelope envelope)
Parameters
envelopeIRawInboundEnvelopeThe envelope.
Returns
- int
The current failed attempts count after the increment.
RollbackAsync(IBrokerMessageIdentifier)
ValueTask RollbackAsync(IBrokerMessageIdentifier brokerMessageIdentifier)
Parameters
brokerMessageIdentifierIBrokerMessageIdentifierThe identifier of the message to be rolled back.
Returns
RollbackAsync(IReadOnlyCollection<IBrokerMessageIdentifier>)
ValueTask RollbackAsync(IReadOnlyCollection<IBrokerMessageIdentifier> brokerMessageIdentifiers)
Parameters
brokerMessageIdentifiersIReadOnlyCollection<IBrokerMessageIdentifier>The identifiers of to messages be rolled back.
Returns
StartAsync()
Starts consuming. Used after StopAsync(bool) has been called to resume consuming.
ValueTask StartAsync()
Returns
StopAsync(bool)
Stops the consumer without disconnecting. Can be used to pause and resume consuming.
ValueTask StopAsync(bool waitUntilStopped = true)
Parameters
waitUntilStoppedboolA value indicating whether the method should wait until the consumer has been effectively stopped.
Returns
- ValueTask
A Task representing the asynchronous operation. This Task will complete as soon as the stopping signal has been sent.
TriggerReconnectAsync()
Stops the consumer and starts an asynchronous Task to disconnect and reconnect it.
ValueTask TriggerReconnectAsync()
Returns
- ValueTask
A Task representing the asynchronous operation. This Task will complete as soon as the stopping signal has been sent, while the process will be completed in another asynchronous Task.
Remarks
This is used to recover when the consumer is stuck in state where it's not able to rollback or commit anymore.