Interface IModel
Common AMQP model, spanning the union of the functionality offered by versions 0-8, 0-8qpid, 0-9 and 0-9-1 of AMQP.
Inherited Members
Namespace: RabbitMQ.Client
Assembly: Apigen.dll
Syntax
public interface IModel : IDisposable
Remarks
Extends the IDisposable interface, so that the "using" statement can be used to scope the lifetime of a channel when appropriate.
Properties
| Edit this page View SourceChannelNumber
Channel number, unique per connections.
Declaration
int ChannelNumber { get; }
Property Value
Type | Description |
---|---|
int |
CloseReason
Returns null if the session is still in a state where it can be used, or the cause of its closure otherwise.
Declaration
ShutdownEventArgs CloseReason { get; }
Property Value
Type | Description |
---|---|
ShutdownEventArgs |
ContinuationTimeout
Amount of time protocol operations (e.g.
queue.declare
) are allowed to take before
timing out.
Declaration
TimeSpan ContinuationTimeout { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
CurrentQueue
The name of the last queue declared on this channel.
Declaration
string CurrentQueue { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
| Edit this page View SourceDefaultConsumer
Signalled when an unexpected message is delivered
Under certain circumstances it is possible for a channel to receive a
message delivery which does not match any consumer which is currently
set up via basicConsume(). This will occur after the following sequence
of events:
ctag = basicConsume(queue, consumer); // i.e. with explicit acks
// some deliveries take place but are not acked
basicCancel(ctag);
basicRecover(false);
Since requeue is specified to be false in the basicRecover, the spec
states that the message must be redelivered to "the original recipient"
- i.e. the same channel / consumer-tag. But the consumer is no longer
active.
In these circumstances, you can register a default consumer to handle
such deliveries. If no default consumer is registered an
InvalidOperationException will be thrown when such a delivery arrives.
Most people will not need to use this.
Declaration
IBasicConsumer DefaultConsumer { get; set; }
Property Value
Type | Description |
---|---|
IBasicConsumer |
IsClosed
Returns true if the model is no longer in a state where it can be used.
Declaration
bool IsClosed { get; }
Property Value
Type | Description |
---|---|
bool |
IsOpen
Returns true if the model is still in a state where it can be used. Identical to checking if CloseReason equals null.
Declaration
bool IsOpen { get; }
Property Value
Type | Description |
---|---|
bool |
NextPublishSeqNo
When in confirm mode, return the sequence number of the next message to be published.
Declaration
ulong NextPublishSeqNo { get; }
Property Value
Type | Description |
---|---|
ulong |
Methods
| Edit this page View SourceAbort()
Abort this session.
Declaration
void Abort()
Remarks
If the session is already closed (or closing), then this method does nothing but wait for the in-progress close operation to complete. This method will not return to the caller until the shutdown is complete. In comparison to normal Close() method, Abort() will not throw Exceptions.AlreadyClosedException or IOException or any other Exception during closing model.
Abort(ushort, string)
Abort this session.
Declaration
void Abort(ushort replyCode, string replyText)
Parameters
Type | Name | Description |
---|---|---|
ushort | replyCode | |
string | replyText |
Remarks
The method behaves in the same way as Abort(), with the only difference that the model is closed with the given model close code and message.
The close code (See under "Reply Codes" in the AMQP specification)
A message indicating the reason for closing the model
BasicAck(ulong, bool)
Acknowledge one or more delivered message(s).
Declaration
void BasicAck(ulong deliveryTag, bool multiple)
Parameters
Type | Name | Description |
---|---|---|
ulong | deliveryTag | |
bool | multiple |
BasicCancel(string)
Delete a Basic content-class consumer.
Declaration
void BasicCancel(string consumerTag)
Parameters
Type | Name | Description |
---|---|---|
string | consumerTag |
BasicCancelNoWait(string)
Same as BasicCancel but sets nowait to true and returns void (as there will be no response from the server).
Declaration
void BasicCancelNoWait(string consumerTag)
Parameters
Type | Name | Description |
---|---|---|
string | consumerTag |
BasicConsume(string, bool, string, bool, bool, IDictionary<string, object>, IBasicConsumer)
Start a Basic content-class consumer.
Declaration
string BasicConsume(string queue, bool autoAck, string consumerTag, bool noLocal, bool exclusive, IDictionary<string, object> arguments, IBasicConsumer consumer)
Parameters
Type | Name | Description |
---|---|---|
string | queue | |
bool | autoAck | |
string | consumerTag | |
bool | noLocal | |
bool | exclusive | |
IDictionary<string, object> | arguments | |
IBasicConsumer | consumer |
Returns
Type | Description |
---|---|
string |
BasicGet(string, bool)
Retrieve an individual message, if one is available; returns null if the server answers that no messages are currently available. See also BasicAck(ulong, bool).
Declaration
BasicGetResult BasicGet(string queue, bool autoAck)
Parameters
Type | Name | Description |
---|---|---|
string | queue | |
bool | autoAck |
Returns
Type | Description |
---|---|
BasicGetResult |
BasicNack(ulong, bool, bool)
Reject one or more delivered message(s).
Declaration
void BasicNack(ulong deliveryTag, bool multiple, bool requeue)
Parameters
Type | Name | Description |
---|---|---|
ulong | deliveryTag | |
bool | multiple | |
bool | requeue |
BasicPublish(string, string, bool, IBasicProperties, ReadOnlyMemory<byte>)
Publishes a message.
Declaration
void BasicPublish(string exchange, string routingKey, bool mandatory, IBasicProperties basicProperties, ReadOnlyMemory<byte> body)
Parameters
Type | Name | Description |
---|---|---|
string | exchange | |
string | routingKey | |
bool | mandatory | |
IBasicProperties | basicProperties | |
ReadOnlyMemory<byte> | body |
Remarks
Routing key must be shorter than 255 bytes.
BasicQos(uint, ushort, bool)
Configures QoS parameters of the Basic content-class.
Declaration
void BasicQos(uint prefetchSize, ushort prefetchCount, bool global)
Parameters
Type | Name | Description |
---|---|---|
uint | prefetchSize | |
ushort | prefetchCount | |
bool | global |
BasicRecover(bool)
Indicates that a consumer has recovered. Deprecated. Should not be used.
Declaration
void BasicRecover(bool requeue)
Parameters
Type | Name | Description |
---|---|---|
bool | requeue |
BasicRecoverAsync(bool)
Indicates that a consumer has recovered. Deprecated. Should not be used.
Declaration
void BasicRecoverAsync(bool requeue)
Parameters
Type | Name | Description |
---|---|---|
bool | requeue |
BasicReject(ulong, bool)
Reject a delivered message.
Declaration
void BasicReject(ulong deliveryTag, bool requeue)
Parameters
Type | Name | Description |
---|---|---|
ulong | deliveryTag | |
bool | requeue |
Close()
Close this session.
Declaration
void Close()
Remarks
If the session is already closed (or closing), then this method does nothing but wait for the in-progress close operation to complete. This method will not return to the caller until the shutdown is complete.
Close(ushort, string)
Close this session.
Declaration
void Close(ushort replyCode, string replyText)
Parameters
Type | Name | Description |
---|---|---|
ushort | replyCode | |
string | replyText |
Remarks
The method behaves in the same way as Close(), with the only difference that the model is closed with the given model close code and message.
The close code (See under "Reply Codes" in the AMQP specification)
A message indicating the reason for closing the model
ConfirmSelect()
Enable publisher acknowledgements.
Declaration
void ConfirmSelect()
ConsumerCount(string)
Returns the number of consumers on a queue. This method assumes the queue exists. If it doesn't, an exception will be closed with an exception.
Declaration
uint ConsumerCount(string queue)
Parameters
Type | Name | Description |
---|---|---|
string | queue | The name of the queue |
Returns
Type | Description |
---|---|
uint |
CreateBasicProperties()
Construct a completely empty content header for use with the Basic content class.
Declaration
IBasicProperties CreateBasicProperties()
Returns
Type | Description |
---|---|
IBasicProperties |
CreateBasicPublishBatch()
Creates a BasicPublishBatch instance
Declaration
IBasicPublishBatch CreateBasicPublishBatch()
Returns
Type | Description |
---|---|
IBasicPublishBatch |
ExchangeBind(string, string, string, IDictionary<string, object>)
Bind an exchange to an exchange.
Declaration
void ExchangeBind(string destination, string source, string routingKey, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | destination | |
string | source | |
string | routingKey | |
IDictionary<string, object> | arguments |
Remarks
Routing key must be shorter than 255 bytes.
ExchangeBindNoWait(string, string, string, IDictionary<string, object>)
Like ExchangeBind but sets nowait to true.
Declaration
void ExchangeBindNoWait(string destination, string source, string routingKey, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | destination | |
string | source | |
string | routingKey | |
IDictionary<string, object> | arguments |
Remarks
Routing key must be shorter than 255 bytes.
ExchangeDeclare(string, string, bool, bool, IDictionary<string, object>)
Declare an exchange.
Declaration
void ExchangeDeclare(string exchange, string type, bool durable, bool autoDelete, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | exchange | |
string | type | |
bool | durable | |
bool | autoDelete | |
IDictionary<string, object> | arguments |
Remarks
The exchange is declared non-passive and non-internal. The "nowait" option is not exercised.
ExchangeDeclareNoWait(string, string, bool, bool, IDictionary<string, object>)
Same as ExchangeDeclare but sets nowait to true and returns void (as there will be no response from the server).
Declaration
void ExchangeDeclareNoWait(string exchange, string type, bool durable, bool autoDelete, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | exchange | |
string | type | |
bool | durable | |
bool | autoDelete | |
IDictionary<string, object> | arguments |
ExchangeDeclarePassive(string)
Do a passive exchange declaration.
Declaration
void ExchangeDeclarePassive(string exchange)
Parameters
Type | Name | Description |
---|---|---|
string | exchange |
Remarks
This method performs a "passive declare" on an exchange, which checks whether an exchange exists. It will do nothing if the exchange already exists and result in a channel-level protocol exception (channel closure) if not.
ExchangeDelete(string, bool)
Delete an exchange.
Declaration
void ExchangeDelete(string exchange, bool ifUnused)
Parameters
Type | Name | Description |
---|---|---|
string | exchange | |
bool | ifUnused |
ExchangeDeleteNoWait(string, bool)
Like ExchangeDelete but sets nowait to true.
Declaration
void ExchangeDeleteNoWait(string exchange, bool ifUnused)
Parameters
Type | Name | Description |
---|---|---|
string | exchange | |
bool | ifUnused |
ExchangeUnbind(string, string, string, IDictionary<string, object>)
Unbind an exchange from an exchange.
Declaration
void ExchangeUnbind(string destination, string source, string routingKey, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | destination | |
string | source | |
string | routingKey | |
IDictionary<string, object> | arguments |
Remarks
Routing key must be shorter than 255 bytes.
ExchangeUnbindNoWait(string, string, string, IDictionary<string, object>)
Like ExchangeUnbind but sets nowait to true.
Declaration
void ExchangeUnbindNoWait(string destination, string source, string routingKey, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | destination | |
string | source | |
string | routingKey | |
IDictionary<string, object> | arguments |
Remarks
Routing key must be shorter than 255 bytes.
MessageCount(string)
Returns the number of messages in a queue ready to be delivered to consumers. This method assumes the queue exists. If it doesn't, an exception will be closed with an exception.
Declaration
uint MessageCount(string queue)
Parameters
Type | Name | Description |
---|---|---|
string | queue | The name of the queue |
Returns
Type | Description |
---|---|
uint |
QueueBind(string, string, string, IDictionary<string, object>)
Bind a queue to an exchange.
Declaration
void QueueBind(string queue, string exchange, string routingKey, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | queue | |
string | exchange | |
string | routingKey | |
IDictionary<string, object> | arguments |
Remarks
Routing key must be shorter than 255 bytes.
QueueBindNoWait(string, string, string, IDictionary<string, object>)
Same as QueueBind but sets nowait parameter to true.
Declaration
void QueueBindNoWait(string queue, string exchange, string routingKey, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | queue | |
string | exchange | |
string | routingKey | |
IDictionary<string, object> | arguments |
Remarks
Routing key must be shorter than 255 bytes.
QueueDeclare(string, bool, bool, bool, IDictionary<string, object>)
Declares a queue. See the Queues guide to learn more.
Declaration
QueueDeclareOk QueueDeclare(string queue, bool durable, bool exclusive, bool autoDelete, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | queue | The name of the queue. Pass an empty string to make the server generate a name. |
bool | durable | Should this queue will survive a broker restart? |
bool | exclusive | Should this queue use be limited to its declaring connection? Such a queue will be deleted when its declaring connection closes. |
bool | autoDelete | Should this queue be auto-deleted when its last consumer (if any) unsubscribes? |
IDictionary<string, object> | arguments | Optional; additional queue arguments, e.g. "x-queue-type" |
Returns
Type | Description |
---|---|
QueueDeclareOk |
QueueDeclareNoWait(string, bool, bool, bool, IDictionary<string, object>)
Same as QueueDeclare but sets nowait to true and returns void (as there will be no response from the server).
Declaration
void QueueDeclareNoWait(string queue, bool durable, bool exclusive, bool autoDelete, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | queue | |
bool | durable | |
bool | exclusive | |
bool | autoDelete | |
IDictionary<string, object> | arguments |
QueueDeclarePassive(string)
Declare a queue passively.
Declaration
QueueDeclareOk QueueDeclarePassive(string queue)
Parameters
Type | Name | Description |
---|---|---|
string | queue |
Returns
Type | Description |
---|---|
QueueDeclareOk |
Remarks
The queue is declared passive, non-durable, non-exclusive, and non-autodelete, with no arguments. The queue is declared passively; i.e. only check if it exists.
QueueDelete(string, bool, bool)
Delete a queue.
Declaration
uint QueueDelete(string queue, bool ifUnused, bool ifEmpty)
Parameters
Type | Name | Description |
---|---|---|
string | queue | |
bool | ifUnused | |
bool | ifEmpty |
Returns
Type | Description |
---|---|
uint |
Remarks
Returns the number of messages purged during queue deletion.
uint.MaxValue
.
QueueDeleteNoWait(string, bool, bool)
Same as QueueDelete but sets nowait parameter to true and returns void (as there will be no response from the server)
Declaration
void QueueDeleteNoWait(string queue, bool ifUnused, bool ifEmpty)
Parameters
Type | Name | Description |
---|---|---|
string | queue | |
bool | ifUnused | |
bool | ifEmpty |
QueuePurge(string)
Purge a queue of messages.
Declaration
uint QueuePurge(string queue)
Parameters
Type | Name | Description |
---|---|---|
string | queue |
Returns
Type | Description |
---|---|
uint |
Remarks
Returns the number of messages purged.
QueueUnbind(string, string, string, IDictionary<string, object>)
Unbind a queue from an exchange.
Declaration
void QueueUnbind(string queue, string exchange, string routingKey, IDictionary<string, object> arguments)
Parameters
Type | Name | Description |
---|---|---|
string | queue | |
string | exchange | |
string | routingKey | |
IDictionary<string, object> | arguments |
Remarks
Routing key must be shorter than 255 bytes.
TxCommit()
Commit this session's active TX transaction.
Declaration
void TxCommit()
TxRollback()
Roll back this session's active TX transaction.
Declaration
void TxRollback()
TxSelect()
Enable TX mode for this session.
Declaration
void TxSelect()
WaitForConfirms()
Wait until all published messages have been confirmed.
Declaration
bool WaitForConfirms()
Returns
Type | Description |
---|---|
bool |
Remarks
Waits until all messages published since the last call have been either ack'd or nack'd by the broker. Returns whether all the messages were ack'd (and none were nack'd). Note, throws an exception when called on a non-Confirm channel.
WaitForConfirms(TimeSpan)
Wait until all published messages have been confirmed.
Declaration
bool WaitForConfirms(TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | How long to wait (at most) before returning whether or not any nacks were returned. |
Returns
Type | Description |
---|---|
bool | True if no nacks were received within the timeout, otherwise false. |
Remarks
Waits until all messages published since the last call have been either ack'd or nack'd by the broker. Returns whether all the messages were ack'd (and none were nack'd). Note, throws an exception when called on a non-Confirm channel.
WaitForConfirms(TimeSpan, out bool)
Wait until all published messages have been confirmed.
Declaration
bool WaitForConfirms(TimeSpan timeout, out bool timedOut)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | How long to wait (at most) before returning whether or not any nacks were returned. |
bool | timedOut | True if the method returned because the timeout elapsed, not because all messages were ack'd or at least one nack'd. |
Returns
Type | Description |
---|---|
bool | True if no nacks were received within the timeout, otherwise false. |
Remarks
Waits until all messages published since the last call have been either ack'd or nack'd by the broker. Returns whether all the messages were ack'd (and none were nack'd). Note, throws an exception when called on a non-Confirm channel.
WaitForConfirmsOrDie()
Wait until all published messages on this channel have been confirmed.
Declaration
void WaitForConfirmsOrDie()
Remarks
Waits until all messages published on this channel since the last call have been ack'd by the broker. If a nack is received, throws an OperationInterrupedException exception immediately and closes the channel.
WaitForConfirmsOrDie(TimeSpan)
Wait until all published messages on this channel have been confirmed.
Declaration
void WaitForConfirmsOrDie(TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout |
Remarks
Waits until all messages published on this channel since the last call have been ack'd by the broker. If a nack is received or the timeout elapses, throws an OperationInterruptedException exception immediately and closes the channel.
Events
| Edit this page View SourceBasicAcks
Signalled when a Basic.Ack command arrives from the broker.
Declaration
event EventHandler<BasicAckEventArgs> BasicAcks
Event Type
Type | Description |
---|---|
EventHandler<BasicAckEventArgs> |
BasicNacks
Signalled when a Basic.Nack command arrives from the broker.
Declaration
event EventHandler<BasicNackEventArgs> BasicNacks
Event Type
Type | Description |
---|---|
EventHandler<BasicNackEventArgs> |
BasicRecoverOk
All messages received before this fires that haven't been ack'ed will be redelivered. All messages received afterwards won't be.
Declaration
event EventHandler<EventArgs> BasicRecoverOk
Event Type
Type | Description |
---|---|
EventHandler<EventArgs> |
Remarks
Handlers for this event are invoked by the connection thread. It is sometimes useful to allow that thread to know that a recover-ok has been received, rather than the thread that invoked BasicRecover(bool).
BasicReturn
Signalled when a Basic.Return command arrives from the broker.
Declaration
event EventHandler<BasicReturnEventArgs> BasicReturn
Event Type
Type | Description |
---|---|
EventHandler<BasicReturnEventArgs> |
CallbackException
Signalled when an exception occurs in a callback invoked by the model.
Examples of cases where this event will be signalled include exceptions thrown in IBasicConsumer methods, or exceptions thrown in ModelShutdown delegates etc.
Declaration
event EventHandler<CallbackExceptionEventArgs> CallbackException
Event Type
Type | Description |
---|---|
EventHandler<CallbackExceptionEventArgs> |
FlowControl
Declaration
event EventHandler<FlowControlEventArgs> FlowControl
Event Type
Type | Description |
---|---|
EventHandler<FlowControlEventArgs> |
ModelShutdown
Notifies the destruction of the model.
Declaration
event EventHandler<ShutdownEventArgs> ModelShutdown
Event Type
Type | Description |
---|---|
EventHandler<ShutdownEventArgs> |
Remarks
If the model is already destroyed at the time an event handler is added to this event, the event handler will be fired immediately.