Class ConnectableProducer

Namespace: redb.Route.Core
Assembly: redb.Route.dll

Base class for connection-based producers.
Handles: started guard, logger resolution, Start/Stop lifecycle.
Subclasses implement and optionally override .

public abstract class ConnectableProducer : IProducer, IProcessor

Inheritance

Object→ConnectableProducer

Implements

Derived

Properties

IsStarted

Whether the producer has been started.

public bool IsStarted { get; }

Logger

Logger resolved from the component.

protected ILogger? Logger { get; }

ProducerEndpoint

The endpoint this producer sends to.

protected abstract IEndpoint ProducerEndpoint { get; }

ProducerName

Display name for logging (e.g. "http:https://api.example.com", "kafka:orders").

protected abstract string ProducerName { get; }

Supervisor

The supervisor of this producer's connection, created on first use with the context's reconnect options

protected ConnectionSupervisor Supervisor { get; }

Methods

ConnectAsync(CancellationToken)

Set up connection/resources. Awaited by Start() to completion before IsStarted flips to

protected abstract Task ConnectAsync(CancellationToken ct)

DisconnectAsync(CancellationToken)

Tear down connection/resources. Called from Stop() after the started flag is cleared.

protected virtual Task DisconnectAsync(CancellationToken ct)

EnsureConnectedAsync(CancellationToken)

Called by before it sends: when the connection was marked lost, either fails at once while

protected Task EnsureConnectedAsync(CancellationToken ct)

EnsureStarted()

Throws if the producer has not been started.

protected void EnsureStarted()

MarkConnectionLost(Exception)

Reports that the connection is lost: from a send, a reply loop, a transacted action's commit or a client callback.

protected void MarkConnectionLost(Exception cause)

OnConnectionLost(Exception)

Fails what waits on the lost connection, such as pending request-reply calls. Default: nothing.

protected virtual void OnConnectionLost(Exception cause)

Process(IExchange, CancellationToken)

Processes the exchange asynchronously.

public abstract Task Process(IExchange exchange, CancellationToken ct = default)

Start(CancellationToken)

Starts the producer.

public Task Start(CancellationToken ct = default)

Stop(CancellationToken)

Stops the producer.

public Task Stop(CancellationToken ct = default)