Class CronTimerTransportAdapter
Cron timer transport adapter that generates synthetic messages on a schedule.
public sealed class CronTimerTransportAdapter : ITransportAdapter, ITransportAdapterLifecycle, ITransportHealthChecker, ITransportHealthMetrics, IAsyncDisposable
- Inheritance
-
CronTimerTransportAdapter
- Implements
- Inherited Members
- Extension Methods
Remarks
This is a trigger-only transport that fires messages according to a cron expression. Unlike other transport adapters that receive messages from external systems, this adapter generates synthetic CronTimerTriggerMessage instances at scheduled intervals.
Key characteristics:
- SendAsync(IDispatchMessage, string, IMessageContext, CancellationToken) is a no-op since this is a receive-only transport
- Messages are generated internally based on the configured cron expression
- Supports 5-field and 6-field (with seconds) cron expressions via ICronScheduler
- TimeZone-aware scheduling with configurable overlap prevention
Implements ITransportHealthChecker for integration with ASP.NET Core health checks and the Excalibur.Dispatch.Transport.MultiTransportHealthCheck.
Constructors
CronTimerTransportAdapter(ILogger<CronTimerTransportAdapter>, ICronScheduler, IServiceProvider, CronTimerTransportAdapterOptions)
Initializes a new instance of the CronTimerTransportAdapter class.
public CronTimerTransportAdapter(ILogger<CronTimerTransportAdapter> logger, ICronScheduler cronScheduler, IServiceProvider serviceProvider, CronTimerTransportAdapterOptions options)
Parameters
loggerILogger<CronTimerTransportAdapter>The logger instance.
cronSchedulerICronSchedulerThe cron scheduler for parsing expressions.
serviceProviderIServiceProviderThe service provider for resolving dependencies.
optionsCronTimerTransportAdapterOptionsThe adapter options.
Fields
DefaultName
The default transport name for cron timer adapters.
public const string DefaultName = "CronTimer"
Field Value
TransportTypeName
The transport type identifier.
public const string TransportTypeName = "crontimer"
Field Value
Properties
IsRunning
Gets a value indicating whether the adapter is currently running.
public bool IsRunning { get; }
Property Value
Name
Gets the unique name of this transport adapter.
public string Name { get; }
Property Value
- string
The adapter identifier.
TransportType
Gets the transport type this adapter handles.
public string TransportType { get; }
Property Value
- string
The transport type managed by the adapter.
Methods
CheckHealthAsync(TransportHealthCheckContext, CancellationToken)
Performs a health check operation.
public Task<TransportHealthCheckResult> CheckHealthAsync(TransportHealthCheckContext context, CancellationToken cancellationToken)
Parameters
contextTransportHealthCheckContextThe health check context.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TransportHealthCheckResult>
The health check result.
CheckQuickHealthAsync(CancellationToken)
Performs a quick health check operation (lighter than full check).
public Task<TransportHealthCheckResult> CheckQuickHealthAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TransportHealthCheckResult>
The health check result.
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
GetHealthMetricsAsync(CancellationToken)
Gets health metrics for this transport.
public Task<TransportHealthMetrics> GetHealthMetricsAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
ReceiveAsync(object, IDispatcher, CancellationToken)
Receives a message from the transport and routes it through the dispatcher.
public Task<IMessageResult> ReceiveAsync(object transportMessage, IDispatcher dispatcher, CancellationToken cancellationToken)
Parameters
transportMessageobjectThe raw transport message.
dispatcherIDispatcherThe dispatcher to route through.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IMessageResult>
The result of message processing.
SendAsync(IDispatchMessage, string, IMessageContext, CancellationToken)
Sends a message through the transport after processing.
public Task SendAsync(IDispatchMessage message, string destination, IMessageContext context, CancellationToken cancellationToken)
Parameters
messageIDispatchMessageThe message to send.
destinationstringThe destination endpoint.
contextIMessageContextThe message context containing correlation, tenant, and other propagation data.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task
Task representing the send operation.
StartAsync(CancellationToken)
Starts the transport adapter.
public Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
StopAsync(CancellationToken)
Stops the transport adapter.
public Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken