Path: redb-route/redb.Route/Abstractions/IProducerTemplate.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/Abstractions/IProducerTemplate.cs ---- namespace redb.Route.Abstractions; /// /// Client API for sending messages to endpoints programmatically, outside of route pipelines. /// Must be started before use via . Supports fire-and-forget, request/reply, /// and processor-based send patterns. Thread-safe after is called. /// public interface IProducerTemplate { /// Gets the route context associated with this template. IRouteContext Context { get; } /// Gets whether this template has been started and is ready for use. bool IsStarted { get; } // ── Synchronous Send ── /// Sends a message body to the specified endpoint URI. /// Target endpoint URI (e.g., "direct:orders"). /// Message body to send. void Send(string endpointUri, object body); /// Sends a message body to the specified endpoint. /// Target endpoint instance. /// Message body to send. void Send(IEndpoint endpoint, object body); /// Sends a pre-built exchange to the specified endpoint. /// Target endpoint instance. /// Exchange to send. void Send(IEndpoint endpoint, IExchange exchange); /// Sends a pre-built exchange to the endpoint resolved from URI. /// Target endpoint URI. /// Exchange to send. void Send(string endpointUri, IExchange exchange); /// Sends a message to the specified endpoint. /// Target endpoint instance. /// Message to wrap in an exchange and send. void Send(IEndpoint endpoint, IMessage message); /// Sends a message to the endpoint resolved from URI. /// Target endpoint URI. /// Message to send. void Send(string endpointUri, IMessage message); /// Applies a processor to an exchange and sends it to the endpoint. /// Target endpoint instance. /// Processor to apply to the exchange before sending. void Send(IEndpoint endpoint, IProcessor processor); // ── Async Send (fire-and-forget) ── /// Asynchronously sends a message body to the endpoint. /// Target endpoint instance. /// Message body to send. Task SendAsync(IEndpoint endpoint, object body); /// Asynchronously sends a message body to the endpoint URI. /// Target endpoint URI. /// Message body to send. Task SendAsync(string endpointUri, object body); /// Asynchronously sends a message to the endpoint. /// Target endpoint instance. /// Message to send. Task SendAsync(IEndpoint endpoint, IMessage message); /// Asynchronously sends a message to the endpoint URI. /// Target endpoint URI. /// Message to send. Task SendAsync(string endpointUri, IMessage message); // ── Async Send of a pre-built exchange (caller-owned) ── /// /// Asynchronously sends a pre-built exchange to the endpoint. /// Unlike the body/message overloads the exchange is caller-owned: it is neither cloned /// nor disposed, and no DI scope is attached — the caller controls its lifetime and any scope /// it carries. Intended for forwarding an existing exchange, e.g. replaying a captured snapshot /// into an internal direct: endpoint. /// /// Target endpoint instance. /// Pre-built exchange to send. /// Token to cancel the in-flight send. Task SendAsync(IEndpoint endpoint, IExchange exchange, CancellationToken cancellationToken = default); /// Asynchronously sends a pre-built, caller-owned exchange to the endpoint resolved from URI. /// Target endpoint URI. /// Pre-built exchange to send. /// Token to cancel the in-flight send. Task SendAsync(string endpointUri, IExchange exchange, CancellationToken cancellationToken = default); // ── Request/Reply ── /// /// Sends a pre-built exchange with and returns the same /// exchange once the producer has populated . The exchange is /// caller-owned — not cloned or disposed — so the caller reads the reply and controls /// its lifetime. /// /// Target endpoint instance. /// Pre-built request exchange. /// Token to cancel the in-flight request. /// The same exchange instance, now carrying the reply in . Task RequestAsync(IEndpoint endpoint, IExchange exchange, CancellationToken cancellationToken = default); /// Sends a pre-built, caller-owned exchange (InOut) by URI and returns it once is populated. /// Target endpoint URI. /// Pre-built request exchange. /// Token to cancel the in-flight request. Task RequestAsync(string endpointUri, IExchange exchange, CancellationToken cancellationToken = default); /// /// Sends a request and waits for the reply body asynchronously. /// Uses to signal request/reply semantics. /// The exchange ends before this method returns, so a reply that reads from resources of its exchange (a streamed /// query result, ) is refused with : read such a /// reply through and dispose the exchange afterwards. /// /// Target endpoint instance. /// Request body. /// Token to cancel the in-flight request. /// The response body from , or null. Task RequestBody(IEndpoint endpoint, object body, CancellationToken cancellationToken = default); /// /// Sends a request by URI and waits for the reply body asynchronously. /// /// Target endpoint URI. /// Request body. /// Token to cancel the in-flight request. /// The response body from , or null. Task RequestBody(string endpointUri, object body, CancellationToken cancellationToken = default); /// /// Sends an explicit as the request and waits for the reply body. /// Headers and ContentType on the message are preserved (the message is not re-wrapped). /// Task RequestBody(IEndpoint endpoint, IMessage message, CancellationToken cancellationToken = default); /// /// Sends an explicit by URI and waits for the reply body. /// Task RequestBody(string endpointUri, IMessage message, CancellationToken cancellationToken = default); /// /// Sends a request and returns the reply body cast to . /// A nullable converts to its underlying type; a reply that does not convert throws /// . /// /// Expected response type. /// Target endpoint instance. /// Request body. /// Token to cancel the in-flight request. /// The typed response body, or default when the reply has no body. Task RequestBody(IEndpoint endpoint, object body, CancellationToken cancellationToken = default); /// /// Sends a request by URI and returns the reply body cast to . /// /// Expected response type. /// Target endpoint URI. /// Request body. /// Token to cancel the in-flight request. /// The typed response body, or default. Task RequestBody(string endpointUri, object body, CancellationToken cancellationToken = default); // ── Lifecycle ── /// Starts the producer template. Must be called before any send/request methods. void Start(); /// Stops the producer template. No send/request methods may be called after this. void Stop(); }