Interface IMessageChannelReceiver<TMessage>
Defines the receive-side contract for a message channel.
public interface IMessageChannelReceiver<TMessage> where TMessage : class
Type Parameters
TMessageThe type of message handled by the channel.
- Extension Methods
Methods
ReceiveAsync(CancellationToken)
Receives a message from the channel.
Task<TMessage?> ReceiveAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA cancellation token to cancel the operation.
Returns
- Task<TMessage>
A task that represents the asynchronous receive operation. The task result contains the received message, or null if no message is available.
ReceiveBatchAsync(int, CancellationToken)
Receives a batch of messages from the channel.
Task<IEnumerable<TMessage>> ReceiveBatchAsync(int maxMessages, CancellationToken cancellationToken)
Parameters
maxMessagesintThe maximum number of messages to receive.
cancellationTokenCancellationTokenA cancellation token to cancel the operation.
Returns
- Task<IEnumerable<TMessage>>
A task that represents the asynchronous batch receive operation. The task result contains the received messages.