Table of Contents

Interface IBrokerClient

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 interface IBrokerClient : IDisposable, IAsyncDisposable
Inherited Members

Properties

Disconnected

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

AsyncEvent<BrokerClient> Disconnected { get; }

Property Value

AsyncEvent<BrokerClient>

Disconnecting

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

AsyncEvent<BrokerClient> Disconnecting { get; }

Property Value

AsyncEvent<BrokerClient>

DisplayName

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

string DisplayName { get; }

Property Value

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.

AsyncEvent<BrokerClient> Initialized { get; }

Property Value

AsyncEvent<BrokerClient>

Initializing

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

AsyncEvent<BrokerClient> Initializing { get; }

Property Value

AsyncEvent<BrokerClient>

Name

Gets the client name.

string Name { get; }

Property Value

string

Status

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

ClientStatus Status { get; }

Property Value

ClientStatus

Methods

ConnectAsync()

Initializes the connection to the message broker.

ValueTask ConnectAsync()

Returns

ValueTask

A Task representing the asynchronous operation.

DisconnectAsync()

Disconnects from the message broker.

ValueTask DisconnectAsync()

Returns

ValueTask

A ValueTask representing the asynchronous operation.

ReconnectAsync()

Disconnects and reconnects the client.

ValueTask ReconnectAsync()

Returns

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.