Table of Contents

EnsureConnectivityAsync Method

Definition

Namespace
Savvyio.Extensions.RabbitMQ
Assemblies
Savvyio.Extensions.RabbitMQ.dll
Source
src/Savvyio.Extensions.RabbitMQ/RabbitMqMessage.cs

EnsureConnectivityAsync(CancellationToken)

Ensures that a connection and channel to the RabbitMQ broker are established and initialized. This method is thread-safe and will only initialize the connection and channel once.

protected Task EnsureConnectivityAsync(CancellationToken ct)

Parameters

ct CancellationToken

A CancellationToken that can be used to cancel the asynchronous operation.

Returns

Task

A Task representing the asynchronous operation.

Remarks

If the connection and channel are already initialized, this method returns immediately. Otherwise, it acquires an asynchronous lock to ensure only one initialization occurs, then creates the RabbitMQ connection and channel.