public class DefaultBasicConsumer

Known direct subtypes: EventingBasicConsumer, QueueingBasicConsumer

Summary

Useful default/base implementation of . Subclass and override in application code.

Remarks

Note that the "Handle*" methods run in the connection's thread! Consider using , which uses a 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.

Field Summary

Flags Type Name Summary
public EventHandler<ConsumerEventArgs> m_consumerCancelled

(undocumented)

public initonly object m_eventLock

(undocumented)

Property Summary

Flags Type Name Summary
public string ConsumerTag (rw)

Retrieve the consumer tag this consumer is registered as; to be used when discussing this consumer with the server, for instance with .

public bool IsRunning (rw)

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

public virtual final IModel Model (rw)

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

public ShutdownEventArgs ShutdownReason (rw)

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

Event Summary

Type Name Summary
EventHandler<ConsumerEventArgs> ConsumerCancelled

Signalled when the consumer gets cancelled.

Constructor Summary

Flags Name Summary
public DefaultBasicConsumer()

Creates a new instance of an .

public DefaultBasicConsumer(IModel model)

Constructor which sets the Model property to the given value.

Method Summary

Flags Name Summary
public virtual void HandleBasicCancel(string consumerTag)

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

public virtual void HandleBasicCancelOk(string consumerTag)

Called upon successful deregistration of the consumer from the broker.

public virtual void HandleBasicConsumeOk(string consumerTag)

Called upon successful registration of the consumer with the broker.

public virtual void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body)

Called each time a message arrives for this consumer.

public virtual void HandleModelShutdown(object model, ShutdownEventArgs reason)

Called when the model shuts down.

public virtual void OnCancel()

Default implementation - overridable in subclasses.

Field Detail

public EventHandler<ConsumerEventArgs> m_consumerCancelled

public initonly object m_eventLock

Property Detail

public string ConsumerTag (rw)

Summary

Retrieve the consumer tag this consumer is registered as; to be used when discussing this consumer with the server, for instance with .

public bool IsRunning (rw)

Summary

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

public virtual final IModel Model (rw)

Summary

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

public ShutdownEventArgs ShutdownReason (rw)

Summary

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

Event Detail

EventHandler<ConsumerEventArgs> ConsumerCancelled

Summary

Signalled when the consumer gets cancelled.

Constructor Detail

DefaultBasicConsumer

public DefaultBasicConsumer()

Summary

Creates a new instance of an .

DefaultBasicConsumer

public DefaultBasicConsumer(IModel model)

Parameters
Name Type
model IModel

Summary

Constructor which sets the Model property to the given value.

Param

Common AMQP model.

Method Detail

HandleBasicCancel

public virtual void HandleBasicCancel(string consumerTag)

Flags public virtual
Return type void
Parameters
Name Type
consumerTag string

Summary

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

Param

Consumer tag this consumer is registered.

HandleBasicCancelOk

public virtual void HandleBasicCancelOk(string consumerTag)

Flags public virtual
Return type void
Parameters
Name Type
consumerTag string

Summary

Called upon successful deregistration of the consumer from the broker.

Param

Consumer tag this consumer is registered.

HandleBasicConsumeOk

public virtual void HandleBasicConsumeOk(string consumerTag)

Flags public virtual
Return type void
Parameters
Name Type
consumerTag string

Summary

Called upon successful registration of the consumer with the broker.

Param

Consumer tag this consumer is registered.

HandleBasicDeliver

public virtual void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body)

Flags public virtual
Return type void
Parameters
Name Type
consumerTag string
deliveryTag ulong
redelivered bool
exchange string
routingKey string
properties IBasicProperties
body byte[]

Summary

Called each time a message arrives for this consumer.

Remarks

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

HandleModelShutdown

public virtual void HandleModelShutdown(object model, ShutdownEventArgs reason)

Flags public virtual
Return type void
Parameters
Name Type
model object
reason ShutdownEventArgs

Summary

Called when the model shuts down.

Param

Common AMQP model.

Param

Information about the reason why a particular model, session, or connection was destroyed.

OnCancel

public virtual void OnCancel()

Flags public virtual
Return type void

Summary

Default implementation - overridable in subclasses.

Remarks

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