Table of Contents

Class IConnectionExtensions

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

Methods

AbortAsync(IConnection)

Asynchronously abort this connection and all its channels.

public static Task AbortAsync(this IConnection connection)

Parameters

connection IConnection

Returns

Task

Remarks

Note that all active channels and sessions will be closed if this method is called. In comparison to normal CloseAsync(IConnection, CancellationToken) method, AbortAsync(IConnection) will not throw IOException during closing connection. This method waits infinitely for the in-progress close operation to complete.

AbortAsync(IConnection, TimeSpan)

Asynchronously abort this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

public static Task AbortAsync(this IConnection connection, TimeSpan timeout)

Parameters

connection IConnection
timeout TimeSpan

Returns

Task

Remarks

This method, behaves in a similar way as method AbortAsync(IConnection) with the only difference that it explicitly specifies a timeout given for all the in-progress close operations to complete. If timeout is reached and the close operations haven't finished, then socket is forced to close.

To wait infinitely for the close operations to complete use Infinite.

AbortAsync(IConnection, ushort, string)

Asynchronously abort this connection and all its channels.

public static Task AbortAsync(this IConnection connection, ushort reasonCode, string reasonText)

Parameters

connection IConnection
reasonCode ushort
reasonText string

Returns

Task

Remarks

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

The close code (See under "Reply Codes" in the AMQP 0-9-1 specification)

A message indicating the reason for closing the connection

AbortAsync(IConnection, ushort, string, TimeSpan)

Asynchronously abort this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

public static Task AbortAsync(this IConnection connection, ushort reasonCode, string reasonText, TimeSpan timeout)

Parameters

connection IConnection
reasonCode ushort
reasonText string
timeout TimeSpan

Returns

Task

Remarks

The method behaves in the same way as AbortAsync(IConnection, TimeSpan), with the only difference that the connection is closed with the given connection close code and message.

The close code (See under "Reply Codes" in the AMQP 0-9-1 specification).

A message indicating the reason for closing the connection.

CloseAsync(IConnection, CancellationToken)

Asynchronously close this connection and all its channels.

public static Task CloseAsync(this IConnection connection, CancellationToken cancellationToken = default)

Parameters

connection IConnection
cancellationToken CancellationToken

Returns

Task

Remarks

Note that all active channels and sessions will be closed if this method is called. It will wait for the in-progress close operation to complete. This method will not return to the caller until the shutdown is complete. If the connection is already closed (or closing), then this method will do nothing. It can also throw IOException when socket was closed unexpectedly.

CloseAsync(IConnection, TimeSpan)

Asynchronously close this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

public static Task CloseAsync(this IConnection connection, TimeSpan timeout)

Parameters

connection IConnection
timeout TimeSpan

Returns

Task

Remarks

Note that all active channels and sessions will be closed if this method is called. It will wait for the in-progress close operation to complete with a timeout. If the connection is already closed (or closing), then this method will do nothing. It can also throw IOException when socket was closed unexpectedly. If timeout is reached and the close operations haven't finished, then socket is forced to close.

To wait infinitely for the close operations to complete use InfiniteTimeSpan.

CloseAsync(IConnection, ushort, string, CancellationToken)

Asynchronously close this connection and all its channels.

public static Task CloseAsync(this IConnection connection, ushort reasonCode, string reasonText, CancellationToken cancellationToken = default)

Parameters

connection IConnection
reasonCode ushort
reasonText string
cancellationToken CancellationToken

Returns

Task

Remarks

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

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

A message indicating the reason for closing the connection.

CloseAsync(IConnection, ushort, string, TimeSpan)

Asynchronously close this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

public static Task CloseAsync(this IConnection connection, ushort reasonCode, string reasonText, TimeSpan timeout)

Parameters

connection IConnection
reasonCode ushort
reasonText string
timeout TimeSpan

Returns

Task

Remarks

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

The close code (See under "Reply Codes" in the AMQP 0-9-1 specification).

A message indicating the reason for closing the connection.

Operation timeout.