Path: redb-route/redb.Route/Batching/IBatchSettlement.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Batching/IBatchSettlement.cs
----
using redb.Route.Abstractions;
namespace redb.Route.Batching;
///
/// How a broker settles the messages of a batch: the one part of batch mode that differs by broker. Kafka settles by
/// position (the last offset of each partition covers the earlier ones); the other brokers settle each message (a
/// delivery tag, a receipt, a lock token). calls exactly one of
/// , or per batch, once the route has
/// returned.
///
public interface IBatchSettlement
{
///
/// Called after the batch exchange is built and before the route runs, with the scope the route runs in: a
/// transport that offers its settlement to the route (Kafka's offsets to a transaction) does it here, a transport that
/// settles on receipt (an automatic acknowledgement) settles here. The returned object, when there is one, is
/// disposed once the route has returned, before the outcome is settled.
///
ValueTask BeforeRouteAsync(IExchange batch, IReadOnlyList items, CancellationToken ct);
/// The route succeeded: settle every message as consumed.
ValueTask AcceptAsync(IExchange batch, IReadOnlyList items, CancellationToken ct);
///
/// The route failed: settle the messages by the connector's rule for a failed single message, applied to every
/// message of the batch (Kafka: breakOnFirstError; RabbitMQ: retries, then reject without requeue).
///
ValueTask RejectAsync(IExchange batch, IReadOnlyList items, Exception failure, CancellationToken ct);
///
/// The batch did not run to an outcome: the consumer stopped while collecting it, or cancelled it while it ran.
/// Give every message back to the broker unsettled, so it is delivered again.
///
ValueTask ReturnAsync(IReadOnlyList items, CancellationToken ct);
}