Path: redb/redb.Templates/templates/route-xml/redb-route-sql/routes/OutboxReportRoute.cs
Snapshot: redb, 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
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Templates/templates/route-xml/redb-route-sql/routes/OutboxReportRoute.cs
----
using redb.Route.Core;
namespace RouteModule.Routes;
///
/// A sibling of routes/outbox.route.xml in C#: a report of orders_outbox on a timer of its own, through the same
/// main-db bean. It only reads the table, so it never takes a row from the XML reader.
///
public sealed class OutboxReportRoute : RouteBuilder
{
protected override void Configure()
{
// Every {{report.period:30000}} ms the number of rows per status. The query is the same on SQLite,
// PostgreSQL and SQL Server; the rows arrive as a list of column dictionaries.
From("timer://cs-modulectx-report?period={{report.period:30000}}")
.RouteId("cs-modulectx-outbox-report")
.Description("Logs how many outbox rows are new, done and failed")
.To("sql:SELECT status, COUNT(*) AS n FROM orders_outbox GROUP BY status?dataSource=#main-db&outputType=SelectList")
.Process(exchange =>
{
var counts = new int[3];
foreach (var row in (IEnumerable>)exchange.In.Body!)
counts[Convert.ToInt32(row["status"])] = Convert.ToInt32(row["n"]);
exchange.In.Body = $"outbox: {counts[0]} new, {counts[1]} done, {counts[2]} failed";
})
.Log("${body}");
}
}