Path: redb/redb.Templates/templates/redb-worker/RedbWorker.Module/Routes/OrderInboxRouteBuilder.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/redb-worker/RedbWorker.Module/Routes/OrderInboxRouteBuilder.cs ---- using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.File; using redb.Route.RedbCore.Extensions; using RedbWorker.Module.Services; using RedbWorker.Module.Xml; namespace RedbWorker.Module.Routes; /// /// inbox -> schema check -> one transaction in redb -> receipt in the outbox. /// /// A processed file moves to the archive, a file that failed moves to the error folder. /// A schema violation is the sender's mistake, not a failure: /// answers it with a Rejected receipt and the file goes to the archive like any other. /// Anything else (the file is not XML at all, the database is down) fails the exchange: the /// transaction rolls back and the file goes to the error folder. /// /// public sealed class OrderInboxRouteBuilder : RouteBuilder { protected override void Configure() { var settings = ModuleSettings.FromContext(Context!); From(FileDsl.Read(settings.Inbox) .Include("*.xml") .Delay(1000) .MoveTo(settings.Archive) // Without MoveFailed a failed file stays in the inbox and is picked up again on the next // poll: the better choice when failures are temporary, such as a database restart. .MoveFailed(settings.Error)) .RouteId("order-inbox") .SetHeader(WorkerHeaders.FileName, e => e.In.GetHeader(FileHeaders.FileNameOnly)) .ConvertBody() .Log("${header.worker.fileName}: received") .ValidateXsd(XmlSchemas.Order) .Unmarshal("application/xml") // Everything the order writes to redb commits together or not at all. .Transacted() .ProcessWithRedb(OrderService.RegisterAsync) .EndTransaction() .Log("${header.worker.fileName}: order ${header.worker.orderId} ${header.worker.status}") .To(RouteUris.WriteReceipt); // The receipt, shared by this route and by the exception handler. From(RouteUris.WriteReceipt) .RouteId("write-receipt") .Marshal("application/xml") .To(FileDsl.Write(settings.Outbox).FileName("${header.worker.fileName}.receipt.xml")); } } /// Internal endpoints of the module. public static class RouteUris { public const string WriteReceipt = "direct:write-receipt"; }