Interface IBasicConsumer
Consumer interface. Used to receive messages from a queue by subscription.
public interface IBasicConsumer
Remarks
See IModel.BasicConsume, IModel.BasicCancel.
Note that the "Handle*" methods run in the connection's thread! Consider using EventingBasicConsumer, which uses a SharedQueue instance to safely pass received messages across to user threads.
Properties
Model
Retrieve the IModel this consumer is associated with, for use in acknowledging received messages, for instance.
IModel Model { get; }
Property Value
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
void HandleBasicCancel(string consumerTag)
Parameters
consumerTag
stringConsumer tag this consumer is registered.
HandleBasicCancelOk(string)
Called upon successful deregistration of the consumer from the broker.
void HandleBasicCancelOk(string consumerTag)
Parameters
consumerTag
stringConsumer tag this consumer is registered.
HandleBasicConsumeOk(string)
Called upon successful registration of the consumer with the broker.
void HandleBasicConsumeOk(string consumerTag)
Parameters
consumerTag
stringConsumer tag this consumer is registered.
HandleBasicDeliver(string, ulong, bool, string, string, IBasicProperties, ReadOnlyMemory<byte>)
Called each time a message arrives for this consumer.
void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, ReadOnlyMemory<byte> body)
Parameters
consumerTag
stringdeliveryTag
ulongredelivered
boolexchange
stringroutingKey
stringproperties
IBasicPropertiesbody
ReadOnlyMemory<byte>
Remarks
Does nothing with the passed in information. Note that in particular, some delivered messages may require acknowledgement via BasicAck(ulong, bool). The implementation of this method in this class does NOT acknowledge such messages.
HandleModelShutdown(object, ShutdownEventArgs)
Called when the model shuts down.
void HandleModelShutdown(object model, ShutdownEventArgs reason)
Parameters
model
objectCommon AMQP model.
reason
ShutdownEventArgsInformation about the reason why a particular model, session, or connection was destroyed.
Events
ConsumerCancelled
Signalled when the consumer gets cancelled.
event EventHandler<ConsumerEventArgs> ConsumerCancelled