Table of Contents

Class IChannelExtensions

Namespace
RabbitMQ.Client
Assembly
RabbitMQ.Client.dll
public static class IChannelExtensions
Inheritance
IChannelExtensions
Inherited Members

Methods

AbortAsync(IChannel, CancellationToken)

Asynchronously abort this session.

public static Task AbortAsync(this IChannel channel, CancellationToken cancellationToken = default)

Parameters

channel IChannel
cancellationToken CancellationToken

Returns

Task

Remarks

If the session is already closed (or closing), then this method does nothing but wait for the in-progress close operation to complete. This method will not return to the caller until the shutdown is complete. In comparison to normal CloseAsync(IChannel, CancellationToken) method, AbortAsync(IChannel, CancellationToken) will not throw AlreadyClosedException or IOException or any other Exception during closing channel.

BasicConsumeAsync(IChannel, string, bool, IAsyncBasicConsumer, CancellationToken)

Asynchronously start a Basic content-class consumer.

public static Task<string> BasicConsumeAsync(this IChannel channel, string queue, bool autoAck, IAsyncBasicConsumer consumer, CancellationToken cancellationToken = default)

Parameters

channel IChannel
queue string
autoAck bool
consumer IAsyncBasicConsumer
cancellationToken CancellationToken

Returns

Task<string>

BasicConsumeAsync(IChannel, string, bool, string, IAsyncBasicConsumer, CancellationToken)

Asynchronously start a Basic content-class consumer.

public static Task<string> BasicConsumeAsync(this IChannel channel, string queue, bool autoAck, string consumerTag, IAsyncBasicConsumer consumer, CancellationToken cancellationToken = default)

Parameters

channel IChannel
queue string
autoAck bool
consumerTag string
consumer IAsyncBasicConsumer
cancellationToken CancellationToken

Returns

Task<string>

BasicConsumeAsync(IChannel, string, bool, string, IDictionary<string, object?>?, IAsyncBasicConsumer, CancellationToken)

Asynchronously start a Basic content-class consumer.

public static Task<string> BasicConsumeAsync(this IChannel channel, string queue, bool autoAck, string consumerTag, IDictionary<string, object?>? arguments, IAsyncBasicConsumer consumer, CancellationToken cancellationToken = default)

Parameters

channel IChannel
queue string
autoAck bool
consumerTag string
arguments IDictionary<string, object>
consumer IAsyncBasicConsumer
cancellationToken CancellationToken

Returns

Task<string>

BasicPublishAsync(IChannel, CachedString, CachedString, bool, ReadOnlyMemory<byte>, CancellationToken)

public static ValueTask BasicPublishAsync(this IChannel channel, CachedString exchange, CachedString routingKey, bool mandatory, ReadOnlyMemory<byte> body, CancellationToken cancellationToken = default)

Parameters

channel IChannel
exchange CachedString
routingKey CachedString
mandatory bool
body ReadOnlyMemory<byte>
cancellationToken CancellationToken

Returns

ValueTask

Remarks

The publication occurs with empty BasicProperties

BasicPublishAsync(IChannel, CachedString, CachedString, ReadOnlyMemory<byte>, CancellationToken)

public static ValueTask BasicPublishAsync(this IChannel channel, CachedString exchange, CachedString routingKey, ReadOnlyMemory<byte> body, CancellationToken cancellationToken = default)

Parameters

channel IChannel
exchange CachedString
routingKey CachedString
body ReadOnlyMemory<byte>
cancellationToken CancellationToken

Returns

ValueTask

Remarks

The publication occurs with mandatory=false and empty BasicProperties

BasicPublishAsync(IChannel, string, string, bool, ReadOnlyMemory<byte>, CancellationToken)

public static ValueTask BasicPublishAsync(this IChannel channel, string exchange, string routingKey, bool mandatory, ReadOnlyMemory<byte> body, CancellationToken cancellationToken = default)

Parameters

channel IChannel
exchange string
routingKey string
mandatory bool
body ReadOnlyMemory<byte>
cancellationToken CancellationToken

Returns

ValueTask

Remarks

The publication occurs with empty BasicProperties

BasicPublishAsync(IChannel, string, string, ReadOnlyMemory<byte>, CancellationToken)

public static ValueTask BasicPublishAsync(this IChannel channel, string exchange, string routingKey, ReadOnlyMemory<byte> body, CancellationToken cancellationToken = default)

Parameters

channel IChannel
exchange string
routingKey string
body ReadOnlyMemory<byte>
cancellationToken CancellationToken

Returns

ValueTask

Remarks

The publication occurs with mandatory=false and empty BasicProperties

BasicPublishAsync<T>(IChannel, PublicationAddress, T, ReadOnlyMemory<byte>, CancellationToken)

public static ValueTask BasicPublishAsync<T>(this IChannel channel, PublicationAddress addr, T basicProperties, ReadOnlyMemory<byte> body, CancellationToken cancellationToken = default) where T : IReadOnlyBasicProperties, IAmqpHeader

Parameters

channel IChannel
addr PublicationAddress
basicProperties T
body ReadOnlyMemory<byte>
cancellationToken CancellationToken

Returns

ValueTask

Type Parameters

T

Remarks

The publication occurs with mandatory=false.

CloseAsync(IChannel, CancellationToken)

Asynchronously close this session.

public static Task CloseAsync(this IChannel channel, CancellationToken cancellationToken = default)

Parameters

channel IChannel
cancellationToken CancellationToken

Returns

Task

Remarks

If the session is already closed (or closing), then this method does nothing but wait for the in-progress close operation to complete. This method will not return to the caller until the shutdown is complete.

CloseAsync(IChannel, ushort, string, CancellationToken)

Asynchronously close this channel.

public static Task CloseAsync(this IChannel channel, ushort replyCode, string replyText, CancellationToken cancellationToken = default)

Parameters

channel IChannel

The channel.

replyCode ushort

The reply code.

replyText string

The reply text.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

Remarks

The method behaves in the same way as CloseAsync(), with the only difference that the channel is closed with the given channel close code and message.

The close code (See under "Reply Codes" in the AMQP specification)

A message indicating the reason for closing the channel

ExchangeDeclareAsync(IChannel, string, string, bool, bool, IDictionary<string, object?>?, bool, CancellationToken)

Asynchronously declare an exchange.

public static Task ExchangeDeclareAsync(this IChannel channel, string exchange, string type, bool durable = false, bool autoDelete = false, IDictionary<string, object?>? arguments = null, bool noWait = false, CancellationToken cancellationToken = default)

Parameters

channel IChannel
exchange string
type string
durable bool
autoDelete bool
arguments IDictionary<string, object>
noWait bool
cancellationToken CancellationToken

Returns

Task

QueueDeclareAsync(IChannel, string, bool, bool, bool, IDictionary<string, object?>?, bool, CancellationToken)

Asynchronously declare a queue.

public static Task<QueueDeclareOk> QueueDeclareAsync(this IChannel channel, string queue = "", bool durable = false, bool exclusive = true, bool autoDelete = true, IDictionary<string, object?>? arguments = null, bool noWait = false, CancellationToken cancellationToken = default)

Parameters

channel IChannel
queue string
durable bool
exclusive bool
autoDelete bool
arguments IDictionary<string, object>
noWait bool
cancellationToken CancellationToken

Returns

Task<QueueDeclareOk>

QueueDeleteAsync(IChannel, string, bool, bool, CancellationToken)

Asynchronously deletes a queue.

public static Task<uint> QueueDeleteAsync(this IChannel channel, string queue, bool ifUnused = false, bool ifEmpty = false, CancellationToken cancellationToken = default)

Parameters

channel IChannel
queue string
ifUnused bool
ifEmpty bool
cancellationToken CancellationToken

Returns

Task<uint>

QueueUnbindAsync(IChannel, string, string, string, IDictionary<string, object?>?, CancellationToken)

Asynchronously unbinds a queue.

public static Task QueueUnbindAsync(this IChannel channel, string queue, string exchange, string routingKey, IDictionary<string, object?>? arguments = null, CancellationToken cancellationToken = default)

Parameters

channel IChannel
queue string
exchange string
routingKey string
arguments IDictionary<string, object>
cancellationToken CancellationToken

Returns

Task