Skip to content

IBrokerDescriptor

IBrokerDescriptor is the common descriptor contract used by the current RabbitMQ descriptor model.

It exposes the shared broker-client option used to enable channel event observation.


Definition

public interface IBrokerDescriptor
{
    bool EnableChannelEvents { get; }
}

Purpose

IBrokerDescriptor allows bound clients to determine whether RabbitMQ channel events should be registered.

When enabled, clients expose channel events through:

IAsyncBrokerClient.OnChannelEventFired

EnableChannelEvents

EnableChannelEvents controls whether the client should observe RabbitMQ channel-level events.

var descriptor = new PublisherBoundDescriptor
{
    EnableChannelEvents = true
};

or:

var descriptor = new SubscriberBoundDescriptor
{
    EnableChannelEvents = true
};

Runtime Flow

graph LR
    Descriptor["Descriptor"]
    Client["Bound Client"]
    RabbitMQ["RabbitMQ Channel Events"]
    Handler["OnChannelEventFired"]

    Descriptor --> Client
    Client --> RabbitMQ
    RabbitMQ --> Handler

Channel Events

Channel events are exposed as ChannelEventArgs.

Common event tags include:

EventTag Description
FlowControl RabbitMQ changed the channel flow-control state.
CallbackException RabbitMQ raised a callback exception.
ModelShutdown The channel/model was shut down.

Publisher Example

publisher.OnChannelEventFired.Add(
    async (sender, args) =>
    {
        Console.WriteLine(args.EventTag);
        Console.WriteLine(args.ToString());

        await Task.CompletedTask;
    });

Subscriber Example

subscriber.OnChannelEventFired.Add(
    async (sender, args) =>
    {
        Console.WriteLine(args.EventTag);
        Console.WriteLine(args.ToString());

        await Task.CompletedTask;
    });

See:

How To / Publishing / Channel Events
How To / Consuming / Channel Events

  • PublisherBoundDescriptor
  • SubscriberBoundDescriptor