C# Class RabbitMQ.Client.DefaultBasicConsumer

Useful default/base implementation of IBasicConsumer. Subclass and override HandleBasicDeliver in application code.
Note that the "Handle*" methods run in the connection's thread! Consider using QueueingBasicConsumer, which uses a SharedQueue instance to safely pass received messages across to user threads, or RabbitMQ.Client.MessagePatterns.Subscription, which manages resource declaration and binding in addition to providing a thread-safe interface.
Inheritance: IBasicConsumer
显示文件 Open project: rabbitmq/rabbitmq-dotnet-client Class Usage Examples

Public Properties

Property Type Description
m_consumerCancelled EventHandler
m_eventLock object

Public Methods

Method Description
DefaultBasicConsumer ( ) : System

Creates a new instance of an DefaultBasicConsumer.

DefaultBasicConsumer ( IModel model ) : System

Constructor which sets the Model property to the given value.

HandleBasicCancel ( string consumerTag ) : void

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 for notification of consumer cancellation due to basicCancel

HandleBasicCancelOk ( string consumerTag ) : void

Called upon successful deregistration of the consumer from the broker.

HandleBasicConsumeOk ( string consumerTag ) : void

Called upon successful registration of the consumer with the broker.

HandleBasicDeliver ( string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte body ) : void

Called each time a message arrives for this consumer.

Does nothing with the passed in information. Note that in particular, some delivered messages may require acknowledgement via IModel.BasicAck. The implementation of this method in this class does NOT acknowledge such messages.

HandleModelShutdown ( object model, RabbitMQ.Client.ShutdownEventArgs reason ) : void

Called when the model shuts down.

OnCancel ( ) : void

Default implementation - overridable in subclasses.

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

Method Details

DefaultBasicConsumer() public method

Creates a new instance of an DefaultBasicConsumer.
public DefaultBasicConsumer ( ) : System
return System

DefaultBasicConsumer() public method

Constructor which sets the Model property to the given value.
public DefaultBasicConsumer ( IModel model ) : System
model IModel Common AMQP model.
return System

HandleBasicCancel() public method

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 for notification of consumer cancellation due to basicCancel
public HandleBasicCancel ( string consumerTag ) : void
consumerTag string Consumer tag this consumer is registered.
return void

HandleBasicCancelOk() public method

Called upon successful deregistration of the consumer from the broker.
public HandleBasicCancelOk ( string consumerTag ) : void
consumerTag string Consumer tag this consumer is registered.
return void

HandleBasicConsumeOk() public method

Called upon successful registration of the consumer with the broker.
public HandleBasicConsumeOk ( string consumerTag ) : void
consumerTag string Consumer tag this consumer is registered.
return void

HandleBasicDeliver() public method

Called each time a message arrives for this consumer.
Does nothing with the passed in information. Note that in particular, some delivered messages may require acknowledgement via IModel.BasicAck. The implementation of this method in this class does NOT acknowledge such messages.
public HandleBasicDeliver ( string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte body ) : void
consumerTag string
deliveryTag ulong
redelivered bool
exchange string
routingKey string
properties IBasicProperties
body byte
return void

HandleModelShutdown() public method

Called when the model shuts down.
public HandleModelShutdown ( object model, RabbitMQ.Client.ShutdownEventArgs reason ) : void
model object Common AMQP model.
reason RabbitMQ.Client.ShutdownEventArgs Information about the reason why a particular model, session, or connection was destroyed.
return void

OnCancel() public method

Default implementation - overridable in subclasses.
This default implementation simply sets the IsRunning property to false, and takes no further action.
public OnCancel ( ) : void
return void

Property Details

m_consumerCancelled public_oe property

public EventHandler m_consumerCancelled
return EventHandler

m_eventLock public_oe property

public object m_eventLock
return object