Interface ITransportSender
Defines the minimal interface for sending messages to a transport destination.
Replaces the bloated ICloudMessagePublisher (10 methods) with a focused contract (3 methods + GetService).
public interface ITransportSender : IAsyncDisposable
- Inherited Members
- Extension Methods
Remarks
Follows the Microsoft.Extensions.AI IChatClient pattern:
- Minimal surface area — only core send operations.
- Transport-specific features via Properties with well-known keys.
- Direct SDK access via GetService(Type) for advanced scenarios.
- Cross-cutting concerns (telemetry, ordering, dedup) via DelegatingTransportSender decorators.
Properties
Destination
Gets the destination name (queue or topic) this sender is configured for.
string Destination { get; }
Property Value
- string
The destination name.
Methods
FlushAsync(CancellationToken)
Flushes any pending messages in internal buffers.
Task FlushAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token for the operation.
Returns
- Task
Task representing the flush operation.
GetService(Type)
Gets the underlying transport service (e.g., IProducer, ServiceBusSender, IAmazonSQS).
object? GetService(Type serviceType)
Parameters
serviceTypeTypeThe type of service to retrieve.
Returns
Remarks
Follows the IChatClient.GetService() pattern from Microsoft.Extensions.AI.
Returns null if the requested service type is not available.
The default implementation answers for any service this instance itself implements, so a transport that provides one directly need not override it. A transport overrides it to hand out its native SDK handle, and a decorator overrides it to answer for itself before deferring to the transport it wraps.
Exceptions
- ArgumentNullException
Thrown when
serviceTypeis null.
SendAsync(TransportMessage, CancellationToken)
Sends a single message to the destination.
Task<SendResult> SendAsync(TransportMessage message, CancellationToken cancellationToken)
Parameters
messageTransportMessageThe message to send.
cancellationTokenCancellationTokenCancellation token for the operation.
Returns
- Task<SendResult>
The result of the send operation.
SendBatchAsync(IReadOnlyList<TransportMessage>, CancellationToken)
Sends multiple messages as a batch to the destination.
Task<BatchSendResult> SendBatchAsync(IReadOnlyList<TransportMessage> messages, CancellationToken cancellationToken)
Parameters
messagesIReadOnlyList<TransportMessage>The messages to send.
cancellationTokenCancellationTokenCancellation token for the operation.
Returns
- Task<BatchSendResult>
The results of the batch send operation. Results carries exactly one entry per input, index-aligned with
messages; see that property for the full contract every implementation must satisfy, including how entries that took a fallback path are reported.