Path: redb-route/demo/SerialNumbersDemo/SerialNumbers.Core/Routes/Outbound/OutboxRouteBuilder.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/demo/SerialNumbersDemo/SerialNumbers.Core/Routes/Outbound/OutboxRouteBuilder.cs ---- using redb.Route.Core; using redb.Route.RedbCore.Extensions; using redb.Route.Sql; using SerialNumbers.Core.Services; namespace SerialNumbers.Core.Routes.Outbound; /// /// Delivers queued responses. The sql: consumer polls the outbox; every row is one exchange. /// /// A delivered row is marked sent; a failed one counts the attempt and keeps the error, and is tried /// again on the next poll, up to ten times. The row is marked after the delivery, so a crash between /// the two sends the file once more: at-least-once, the partner recognises a repeat by the file name. /// /// public sealed class OutboxRouteBuilder : RouteBuilder { protected override void Configure() { From(Sql.Poll("SELECT TOP (20) id, partner_code, response_object_id FROM dbo.outbox " + "WHERE sent_at IS NULL AND attempts < 10 ORDER BY id") .DataSource(Constant(RegistryNames.SerialsDatabase)) .Delay(2000) .OnSuccess("UPDATE dbo.outbox SET sent_at = SYSUTCDATETIME(), attempts = attempts + 1, last_error = NULL WHERE id = :#id") .OnFailure("UPDATE dbo.outbox SET attempts = attempts + 1, last_error = LEFT(:#redbError, 2000) WHERE id = :#id")) .RouteId("outbox") .ProcessWithRedb(ResponseRenderer.RenderAsync) .Marshal("application/xml") .ToD(RouteUris.DeliveryForOutboxRow) .Log("${header.partner_code}: delivered ${header.serials.fileName}"); } }