Interface IConsumer
Consumes an endpoint and invokes a callback delegate when a message is received.
Namespace: Silverback.Messaging.Broker
Assembly: Silverback.Integration.dll
Syntax
public interface IConsumer
Properties
| Improve this doc View sourceBroker
Gets the IBroker that owns this consumer.
Declaration
IBroker Broker { get; }
Property Value
Type | Description |
---|---|
IBroker |
Endpoint
Gets the IConsumerEndpoint representing the endpoint that is being consumed.
Declaration
IConsumerEndpoint Endpoint { get; }
Property Value
Type | Description |
---|---|
IConsumerEndpoint |
Id
Gets the InstanceIdentifier uniquely identifying the consumer instance.
Declaration
InstanceIdentifier Id { get; }
Property Value
Type | Description |
---|---|
InstanceIdentifier |
IsConnected
Gets a value indicating whether this consumer has successfully initialized the connection to the message broker.
Declaration
bool IsConnected { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This doesn't necessary mean that it is connected and ready to consume. The underlying library might handle the connection process asynchronously in the background or the protocol might require extra steps (e.g. Kafka might require the partitions to be assigned).
IsConnecting
Gets a value indicating whether this consumer is initializing the connection to the message broker.
Declaration
bool IsConnecting { get; }
Property Value
Type | Description |
---|---|
bool |
IsConsuming
Gets a value indicating whether this consumer is connected and consuming (started).
Declaration
bool IsConsuming { get; }
Property Value
Type | Description |
---|---|
bool |
StatusInfo
Gets the IConsumerStatusInfo containing the status details and basic statistics of this consumer.
Declaration
IConsumerStatusInfo StatusInfo { get; }
Property Value
Type | Description |
---|---|
IConsumerStatusInfo |
Methods
| Improve this doc View sourceCommitAsync(IBrokerMessageIdentifier)
Declaration
Task CommitAsync(IBrokerMessageIdentifier brokerMessageIdentifier)
Parameters
Type | Name | Description |
---|---|---|
IBrokerMessageIdentifier | brokerMessageIdentifier | The identifier of the message to be committed. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
CommitAsync(IReadOnlyCollection<IBrokerMessageIdentifier>)
Declaration
Task CommitAsync(IReadOnlyCollection<IBrokerMessageIdentifier> brokerMessageIdentifiers)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<IBrokerMessageIdentifier> | brokerMessageIdentifiers | The identifiers of to message be committed. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
ConnectAsync()
Connects and starts consuming.
Declaration
Task ConnectAsync()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
DisconnectAsync()
Disconnects and stops consuming.
Declaration
Task DisconnectAsync()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
GetCurrentSequenceStores()
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
IReadOnlyList<ISequenceStore> GetCurrentSequenceStores()
Returns
Type | Description |
---|---|
IReadOnlyList<ISequenceStore> | The list of ISequenceStore. |
IncrementFailedAttempts(IRawInboundEnvelope)
Increments the stored failed attempts count for the specified envelope.
Declaration
int IncrementFailedAttempts(IRawInboundEnvelope envelope)
Parameters
Type | Name | Description |
---|---|---|
IRawInboundEnvelope | envelope | The envelope. |
Returns
Type | Description |
---|---|
int | The current failed attempts count after the increment. |
RollbackAsync(IBrokerMessageIdentifier)
Declaration
Task RollbackAsync(IBrokerMessageIdentifier brokerMessageIdentifier)
Parameters
Type | Name | Description |
---|---|---|
IBrokerMessageIdentifier | brokerMessageIdentifier | The identifier of the message to be rolled back. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
RollbackAsync(IReadOnlyCollection<IBrokerMessageIdentifier>)
Declaration
Task RollbackAsync(IReadOnlyCollection<IBrokerMessageIdentifier> brokerMessageIdentifiers)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<IBrokerMessageIdentifier> | brokerMessageIdentifiers | The identifiers of to message be rolled back. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
StartAsync()
Starts consuming. Used after StopAsync() has been called to resume consuming.
Declaration
Task StartAsync()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
StopAsync()
Stops the consumer without disconnecting. Can be used to pause and resume consuming.
Declaration
Task StopAsync()
Returns
Type | Description |
---|---|
Task | 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.
Declaration
Task TriggerReconnectAsync()
Returns
Type | Description |
---|---|
Task | 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. |