Show / Hide Table of Contents

    Class BrokerClient

    Wraps the underlying client libraries (e.g. Kafka consumers and producers or Mqtt clients) and handles the connection lifecycle.

    Inheritance
    object
    BrokerClient
    Implements
    IBrokerClient
    IDisposable
    IAsyncDisposable
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: Silverback.Messaging.Broker
    Assembly: Silverback.Integration.dll
    Syntax
    public abstract class BrokerClient : IBrokerClient, IDisposable, IAsyncDisposable

    Constructors

    BrokerClient(string, ISilverbackLogger)

    Initializes a new instance of the BrokerClient class.

    Declaration
    protected BrokerClient(string name, ISilverbackLogger logger)
    Parameters
    Type Name Description
    string name

    The client name.

    ISilverbackLogger logger

    The ISilverbackLogger.

    Properties

    Disconnected

    Gets the AsyncEvent<TArg> that is fired when the DisconnectAsync() method has been called and the client is disconnected.

    Declaration
    public AsyncEvent<BrokerClient> Disconnected { get; }
    Property Value
    Type Description
    AsyncEvent<BrokerClient>

    Disconnecting

    Gets the AsyncEvent<TArg> that is fired when the DisconnectAsync() method is called and the client is disconnecting.

    Declaration
    public AsyncEvent<BrokerClient> Disconnecting { get; }
    Property Value
    Type Description
    AsyncEvent<BrokerClient>

    DisplayName

    Gets the name to be displayed in the human-targeted output (e.g. logs, health checks result, etc.).

    Declaration
    public string DisplayName { get; }
    Property Value
    Type Description
    string

    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.

    Declaration
    public AsyncEvent<BrokerClient> Initialized { get; }
    Property Value
    Type Description
    AsyncEvent<BrokerClient>

    Initializing

    Gets the AsyncEvent<TArg> that is fired when the ConnectAsync() method is called and the client is initializing.

    Declaration
    public AsyncEvent<BrokerClient> Initializing { get; }
    Property Value
    Type Description
    AsyncEvent<BrokerClient>

    Name

    Gets the client name.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    string

    Status

    Gets a value indicating whether the client is connected to the broker.

    Declaration
    public ClientStatus Status { get; }
    Property Value
    Type Description
    ClientStatus

    Methods

    ConnectAsync()

    Initializes the connection to the message broker.

    Declaration
    public ValueTask ConnectAsync()
    Returns
    Type Description
    ValueTask

    A Task representing the asynchronous operation.

    ConnectCoreAsync()

    Called when ConnectAsync() is called to initialize the client.

    Declaration
    protected abstract ValueTask ConnectCoreAsync()
    Returns
    Type Description
    ValueTask

    A ValueTask representing the asynchronous operation.

    DisconnectAsync()

    Disconnects from the message broker.

    Declaration
    public ValueTask DisconnectAsync()
    Returns
    Type Description
    ValueTask

    A ValueTask representing the asynchronous operation.

    DisconnectCoreAsync()

    Called when DisconnectAsync() is called to disconnect the client.

    Declaration
    protected abstract ValueTask DisconnectCoreAsync()
    Returns
    Type Description
    ValueTask

    A ValueTask representing the asynchronous operation.

    Dispose()

    Wraps the underlying client libraries (e.g. Kafka consumers and producers or Mqtt clients) and handles the connection lifecycle.

    Declaration
    public void Dispose()

    Dispose(bool)

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    A value indicating whether the method has been called by the Dispose method and not from the finalizer.

    DisposeAsync()

    Wraps the underlying client libraries (e.g. Kafka consumers and producers or Mqtt clients) and handles the connection lifecycle.

    Declaration
    public ValueTask DisposeAsync()
    Returns
    Type Description
    ValueTask

    DisposeCoreAsync()

    Wraps the underlying client libraries (e.g. Kafka consumers and producers or Mqtt clients) and handles the connection lifecycle.

    Declaration
    protected virtual ValueTask DisposeCoreAsync()
    Returns
    Type Description
    ValueTask

    ~BrokerClient()

    Finalizes an instance of the BrokerClient class.

    Declaration
    protected ~BrokerClient()

    ReconnectAsync()

    Disconnects and reconnects the client.

    Declaration
    public ValueTask ReconnectAsync()
    Returns
    Type Description
    ValueTask

    A ValueTask representing the asynchronous operation.

    Remarks

    This is used to recover when the consumer is stuck in state where it's not able to rollback or commit anymore.

    Implements

    IBrokerClient
    IDisposable
    IAsyncDisposable
    GitHub E-Mail
    ↑ Back to top © 2026 Sergio Aquilini