Class BrokerClient
- Namespace
- Silverback.Messaging.Broker
- Assembly
- Silverback.Integration.dll
Wraps the underlying client libraries (e.g. Kafka consumers and producers or Mqtt clients) and handles the connection lifecycle.
public abstract class BrokerClient : IBrokerClient, IDisposable, IAsyncDisposable
- Inheritance
-
BrokerClient
- Implements
- Inherited Members
Constructors
BrokerClient(string, ISilverbackLogger)
Initializes a new instance of the BrokerClient class.
protected BrokerClient(string name, ISilverbackLogger logger)
Parameters
namestringThe client name.
loggerISilverbackLoggerThe ISilverbackLogger.
Properties
Disconnected
Gets the AsyncEvent<TArg> that is fired when the DisconnectAsync() method has been called and the client is disconnected.
public AsyncEvent<BrokerClient> Disconnected { get; }
Property Value
Disconnecting
Gets the AsyncEvent<TArg> that is fired when the DisconnectAsync() method is called and the client is disconnecting.
public AsyncEvent<BrokerClient> Disconnecting { get; }
Property Value
DisplayName
Gets the name to be displayed in the human-targeted output (e.g. logs, health checks result, etc.).
public string DisplayName { get; }
Property Value
Initialized
Gets the AsyncEvent<TArg> that is fired when the ConnectAsync() method has been called and the client has been successfully initialized. The connection with the broker will eventually be established.
public AsyncEvent<BrokerClient> Initialized { get; }
Property Value
Initializing
Gets the AsyncEvent<TArg> that is fired when the ConnectAsync() method is called and the client is initializing.
public AsyncEvent<BrokerClient> Initializing { get; }
Property Value
Name
Gets the client name.
public string Name { get; }
Property Value
Status
Gets a value indicating whether the client is connected to the broker.
public ClientStatus Status { get; }
Property Value
Methods
ConnectAsync()
Initializes the connection to the message broker.
public ValueTask ConnectAsync()
Returns
ConnectCoreAsync()
Called when ConnectAsync() is called to initialize the client.
protected abstract ValueTask ConnectCoreAsync()
Returns
DisconnectAsync()
Disconnects from the message broker.
public ValueTask DisconnectAsync()
Returns
DisconnectCoreAsync()
Called when DisconnectAsync() is called to disconnect the client.
protected abstract ValueTask DisconnectCoreAsync()
Returns
Dispose()
public void Dispose()
Dispose(bool)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingboolA value indicating whether the method has been called by the
Disposemethod and not from the finalizer.
DisposeAsync()
public ValueTask DisposeAsync()
Returns
DisposeCoreAsync()
protected virtual ValueTask DisposeCoreAsync()
Returns
~BrokerClient()
Finalizes an instance of the BrokerClient class.
protected ~BrokerClient()
ReconnectAsync()
Disconnects and reconnects the client.
public ValueTask ReconnectAsync()
Returns
Remarks
This is used to recover when the consumer is stuck in state where it's not able to rollback or commit anymore.