Table of Contents

Class AsyncDefaultBasicConsumer

Namespace
RabbitMQ.Client
Assembly
RabbitMQ.Client.dll
public class AsyncDefaultBasicConsumer : IBasicConsumer, IAsyncBasicConsumer
Inheritance
AsyncDefaultBasicConsumer
Implements
Derived
Inherited Members

Constructors

AsyncDefaultBasicConsumer()

Creates a new instance of an DefaultBasicConsumer.

public AsyncDefaultBasicConsumer()

AsyncDefaultBasicConsumer(IModel)

Constructor which sets the Model property to the given value.

public AsyncDefaultBasicConsumer(IModel model)

Parameters

model IModel

Common AMQP model.

Properties

ConsumerTags

Retrieve the consumer tags this consumer is registered as; to be used when discussing this consumer with the server, for instance with BasicCancel(string).

public string[] ConsumerTags { get; }

Property Value

string[]

IsRunning

Returns true while the consumer is registered and expecting deliveries from the broker.

public bool IsRunning { get; protected set; }

Property Value

bool

Model

Retrieve the IModel this consumer is associated with, for use in acknowledging received messages, for instance.

public IModel Model { get; set; }

Property Value

IModel

ShutdownReason

If our IModel shuts down, this property will contain a description of the reason for the shutdown. Otherwise it will contain null. See ShutdownEventArgs.

public ShutdownEventArgs ShutdownReason { get; protected set; }

Property Value

ShutdownEventArgs

Methods

HandleBasicCancel(string)

Called when the consumer is cancelled for reasons other than by a basicCancel: e.g. the queue has been deleted (either by this channel or by any other channel). See HandleBasicCancelOk(string) for notification of consumer cancellation due to basicCancel

public virtual Task HandleBasicCancel(string consumerTag)

Parameters

consumerTag string

Consumer tag this consumer is registered.

Returns

Task

HandleBasicCancelOk(string)

Called upon successful deregistration of the consumer from the broker.

public virtual Task HandleBasicCancelOk(string consumerTag)

Parameters

consumerTag string

Consumer tag this consumer is registered.

Returns

Task

HandleBasicConsumeOk(string)

Called upon successful registration of the consumer with the broker.

public virtual Task HandleBasicConsumeOk(string consumerTag)

Parameters

consumerTag string

Consumer tag this consumer is registered.

Returns

Task

HandleBasicDeliver(string, ulong, bool, string, string, IBasicProperties, ReadOnlyMemory<byte>)

Called each time a message is delivered for this consumer.

public virtual Task HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, ReadOnlyMemory<byte> body)

Parameters

consumerTag string
deliveryTag ulong
redelivered bool
exchange string
routingKey string
properties IBasicProperties
body ReadOnlyMemory<byte>

Returns

Task

Remarks

This is a no-op implementation. It will not acknowledge deliveries via BasicAck(ulong, bool) if consuming in automatic acknowledgement mode. Subclasses must copy or fully use delivery body before returning. Accessing the body at a later point is unsafe as its memory can be already released.

HandleModelShutdown(object, ShutdownEventArgs)

Called when the model (channel) this consumer was registered on terminates.

public virtual Task HandleModelShutdown(object model, ShutdownEventArgs reason)

Parameters

model object

A channel this consumer was registered on.

reason ShutdownEventArgs

Shutdown context.

Returns

Task

OnCancel(params string[])

Default implementation - overridable in subclasses.

public virtual Task OnCancel(params string[] consumerTags)

Parameters

consumerTags string[]

The set of consumer tags that where cancelled

Returns

Task

Remarks

This default implementation simply sets the IsRunning property to false, and takes no further action.

Events

ConsumerCancelled

Signalled when the consumer gets cancelled.

public event AsyncEventHandler<ConsumerEventArgs> ConsumerCancelled

Event Type

AsyncEventHandler<ConsumerEventArgs>