Interface IBrokerClient
Wraps the underlying client libraries (e.g. Kafka consumers and producers or Mqtt clients) and handles the connection lifecycle.
Namespace: Silverback.Messaging.Broker
Assembly: Silverback.Integration.dll
Syntax
public interface IBrokerClient : IDisposable, IAsyncDisposable
Properties
Disconnected
Gets the AsyncEvent<TArg> that is fired when the DisconnectAsync() method has been called and the client is disconnected.
Declaration
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
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
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
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
AsyncEvent<BrokerClient> Initializing { get; }
Property Value
| Type | Description |
|---|---|
| AsyncEvent<BrokerClient> |
Name
Gets the client name.
Declaration
string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Status
Gets a value indicating whether the client is connected to the broker.
Declaration
ClientStatus Status { get; }
Property Value
| Type | Description |
|---|---|
| ClientStatus |
Methods
ConnectAsync()
Initializes the connection to the message broker.
Declaration
ValueTask ConnectAsync()
Returns
| Type | Description |
|---|---|
| ValueTask | A Task representing the asynchronous operation. |
DisconnectAsync()
Disconnects from the message broker.
Declaration
ValueTask DisconnectAsync()
Returns
| Type | Description |
|---|---|
| ValueTask | A ValueTask representing the asynchronous operation. |
ReconnectAsync()
Disconnects and reconnects the client.
Declaration
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.