Class ProducerTemplate

Namespace: redb.Route.Core
Assembly: redb.Route.dll

Default implementation of .
Provides a client API for sending messages to endpoints outside of route pipelines.
Must be started via before use.
Thread-safe: all public methods check started state, endpoint resolution is delegated
to which uses concurrent collections.
Caches producers per endpoint for performance (avoids CreateProducer on every call).

public class ProducerTemplate : IProducerTemplate, IDisposable, IAsyncDisposable

Inheritance

Object→ProducerTemplate

Implements

Properties

Context

Gets the route context associated with this template.

public IRouteContext Context { get; }

IsStarted

Gets whether this template has been started and is ready for use.

public bool IsStarted { get; }

Methods

Dispose()

Stops the producers the template created (they flush and close) and releases them.

public void Dispose()

DisposeAsync()

Stops the producers the template created (they flush and close) and releases them.

public ValueTask DisposeAsync()

RequestAsync(IEndpoint, IExchange, CancellationToken)

Sends a pre-built exchange with and returns the same

public Task<IExchange> RequestAsync(IEndpoint endpoint, IExchange exchange, CancellationToken cancellationToken = default)

RequestAsync(string, IExchange, CancellationToken)

Sends a pre-built, caller-owned exchange (InOut) by URI and returns it once is populated.

public Task<IExchange> RequestAsync(string endpointUri, IExchange exchange, CancellationToken cancellationToken = default)

RequestBody(IEndpoint, IMessage, CancellationToken)

Sends an explicit as the request and waits for the reply body.

public Task<object?> RequestBody(IEndpoint endpoint, IMessage message, CancellationToken cancellationToken = default)

RequestBody(IEndpoint, object, CancellationToken)

Sends a request and waits for the reply body asynchronously.

public Task<object?> RequestBody(IEndpoint endpoint, object body, CancellationToken cancellationToken = default)

RequestBody(string, IMessage, CancellationToken)

Sends an explicit by URI and waits for the reply body.

public Task<object?> RequestBody(string endpointUri, IMessage message, CancellationToken cancellationToken = default)

RequestBody(string, object, CancellationToken)

Sends a request by URI and waits for the reply body asynchronously.

public Task<object?> RequestBody(string endpointUri, object body, CancellationToken cancellationToken = default)

RequestBody<T>(IEndpoint, object, CancellationToken)

Sends a request and returns the reply body cast to T.

public Task<T?> RequestBody<T>(IEndpoint endpoint, object body, CancellationToken cancellationToken = default)

RequestBody<T>(string, object, CancellationToken)

Sends a request by URI and returns the reply body cast to T.

public Task<T?> RequestBody<T>(string endpointUri, object body, CancellationToken cancellationToken = default)

Send(IEndpoint, IExchange)

Sends a pre-built exchange to the specified endpoint.

public void Send(IEndpoint endpoint, IExchange exchange)

Send(IEndpoint, IMessage)

Sends a message to the specified endpoint.

public void Send(IEndpoint endpoint, IMessage message)

Send(IEndpoint, IProcessor)

Applies a processor to an exchange and sends it to the endpoint.

public void Send(IEndpoint endpoint, IProcessor processor)

Send(IEndpoint, object)

Sends a message body to the specified endpoint.

public void Send(IEndpoint endpoint, object body)

Send(string, IExchange)

Sends a pre-built exchange to the endpoint resolved from URI.

public void Send(string endpointUri, IExchange exchange)

Send(string, IMessage)

Sends a message to the endpoint resolved from URI.

public void Send(string endpointUri, IMessage message)

Send(string, object)

Sends a message body to the specified endpoint URI.

public void Send(string endpointUri, object body)

SendAsync(IEndpoint, IExchange, CancellationToken)

Asynchronously sends a pre-built exchange to the endpoint.

public Task SendAsync(IEndpoint endpoint, IExchange exchange, CancellationToken cancellationToken = default)

SendAsync(IEndpoint, IMessage)

Asynchronously sends a message to the endpoint.

public Task SendAsync(IEndpoint endpoint, IMessage message)

SendAsync(IEndpoint, object)

Asynchronously sends a message body to the endpoint.

public Task SendAsync(IEndpoint endpoint, object body)

SendAsync(string, IExchange, CancellationToken)

Asynchronously sends a pre-built, caller-owned exchange to the endpoint resolved from URI.

public Task SendAsync(string endpointUri, IExchange exchange, CancellationToken cancellationToken = default)

SendAsync(string, IMessage)

Asynchronously sends a message to the endpoint URI.

public Task SendAsync(string endpointUri, IMessage message)

SendAsync(string, object)

Asynchronously sends a message body to the endpoint URI.

public Task SendAsync(string endpointUri, object body)

Start()

Starts the producer template. Must be called before any send/request methods.

public void Start()

Stop()

Stops the template and the producers it created — they flush and close, as a Camel template stops its producer

public void Stop()

Constructors

ProducerTemplate(IRouteContext)

Initializes a new instance with the specified route context.