This page contains a complete reference to RabbitMQ's implementaton of version 0-9-1 of the AMQP specification. The original specification was published by the AMQP WG in 2008 and is made available under the AMQP license.
Elsewhere on this site you can read details of RabbitMQ's conformance to the specification. RabbitMQ implements several extensions to the core specification that are documented in this guide. The original and extended specification downloads can be found on the protocol page.
You may also be interested in our Protocol & API Quick Reference.
The following classes, with their associated methods, are defined in the specification:
Work with socket connections.
The connection class provides methods for a client to establish a network connection to a server, and for both peers to operate the connection thereafter.
Class Grammar:
connection = open-connection *use-connection close-connection open-connection = C:protocol-header S:START C:START-OK *challenge S:TUNE C:TUNE-OK C:OPEN S:OPEN-OK challenge = S:SECURE C:SECURE-OK use-connection = *channel close-connection = C:CLOSE S:CLOSE-OK / S:CLOSE C:CLOSE-OK
Start connection negotiation.
This method starts the connection negotiation process by telling the client the protocol version that the server proposes, along with a list of security mechanisms which the client can use for authentication.
octet version-major
The major version number can take any value from 0 to 99 as defined in the AMQP specification.
octet version-minor
The minor version number can take any value from 0 to 99 as defined in the AMQP specification.
peer-properties server-properties
Server properties.
longstr mechanisms
A list of the security mechanisms that the server supports, delimited by spaces.
longstr locales
A list of the message locales that the server supports, delimited by spaces. The locale defines the language in which the server will send reply texts.
Select security mechanism and locale.
This method selects a SASL security mechanism.
peer-properties client-properties
Client properties.
shortstr mechanism
A single security mechanisms selected by the client, which must be one of those specified by the server.
longstr response
A block of opaque data passed to the security mechanism. The contents of this data are defined by the SASL security mechanism.
shortstr locale
A single message locale selected by the client, which must be one of those specified by the server.
(back to top)Security mechanism challenge.
The SASL protocol works by exchanging challenges and responses until both peers have received sufficient information to authenticate each other. This method challenges the client to provide more information.
longstr challenge
Challenge information, a block of opaque binary data passed to the security mechanism.
(back to top)Security mechanism response.
This method attempts to authenticate, passing a block of SASL data for the security mechanism at the server side.
longstr response
A block of opaque data passed to the security mechanism. The contents of this data are defined by the SASL security mechanism.
(back to top)Propose connection tuning parameters.
This method proposes a set of connection configuration values to the client. The client can accept and/or adjust these.
short channel-max
Specifies highest channel number that the server permits. Usable channel numbers are in the range 1..channel-max. Zero indicates no specified limit.
long frame-max
The largest frame size that the server proposes for the connection, including frame header and end-byte. The client can negotiate a lower value. Zero means that the server does not impose any specific limit but may reject very large frames if it cannot allocate resources for them.
short heartbeat
The delay, in seconds, of the connection heartbeat that the server wants. Zero means the server does not want a heartbeat.
(back to top)Negotiate connection tuning parameters.
This method sends the client's connection tuning parameters to the server. Certain fields are negotiated, others provide capability information.
short channel-max
The maximum total number of channels that the client will use per connection.
long frame-max
The largest frame size that the client and server will use for the connection. Zero means that the client does not impose any specific limit but may reject very large frames if it cannot allocate resources for them. Note that the frame-max limit applies principally to content frames, where large contents can be broken into frames of arbitrary size.
short heartbeat
The delay, in seconds, of the connection heartbeat that the client wants. Zero means the client does not want a heartbeat.
(back to top)Open connection to virtual host.
This method opens a connection to a virtual host, which is a collection of resources, and acts to separate multiple application domains within a server. The server may apply arbitrary limits per virtual host, such as the number of each type of entity that may be used, per connection and/or in total.
path virtual-host
The name of the virtual host to work with.
shortstr reserved-1
bit reserved-2
(back to top)Signal that connection is ready.
This method signals to the client that the connection is ready for use.
shortstr reserved-1
(back to top)Request a connection close.
This method indicates that the sender wants to close the connection. This may be due to internal conditions (e.g. a forced shut-down) or due to an error handling a specific method, i.e. an exception. When a close is due to an exception, the sender provides the class and method id of the method which caused the exception.
reply-code reply-code
reply-text reply-text
class-id class-id
When the close is provoked by a method exception, this is the class of the method.
method-id method-id
When the close is provoked by a method exception, this is the ID of the method.
(back to top)Confirm a connection close.
This method confirms a Connection.Close method and tells the recipient that it is safe to release resources for the connection and close the socket.
Indicate that connection is blocked.
This method indicates that a connection has been blocked and does not accept new publishes.
shortstr reason
The reason the connection was blocked.
(back to top)Indicate that connection is unblocked.
This method indicates that a connection has been unblocked and now accepts publishes.
(back to top)Update secret.
This method updates the secret used to authenticate this connection. It is used when secrets have an expiration date and need to be renewed, like OAuth 2 tokens.
longstr new-secret
The new secret.
shortstr reason
The reason for the secret update.
(back to top)Update secret response.
This method confirms the updated secret is valid.
(back to top)Work with channels.
The channel class provides methods for a client to establish a channel to a server and for both peers to operate the channel thereafter.
Class Grammar:
channel = open-channel *use-channel close-channel open-channel = C:OPEN S:OPEN-OK use-channel = C:FLOW S:FLOW-OK / S:FLOW C:FLOW-OK / functional-class close-channel = C:CLOSE S:CLOSE-OK / S:CLOSE C:CLOSE-OK
Open a channel for use.
This method opens a channel to the server.
shortstr reserved-1
(back to top)Signal that the channel is ready.
This method signals to the client that the channel is ready for use.
longstr reserved-1
(back to top)Enable/disable flow from peer.
This method asks the peer to pause or restart the flow of content data sent by a consumer. This is a simple flow-control mechanism that a peer can use to avoid overflowing its queues or otherwise finding itself receiving more messages than it can process. Note that this method is not intended for window control. It does not affect contents returned by Basic.Get-Ok methods.
bit active
If 1, the peer starts sending content frames. If 0, the peer stops sending content frames.
(back to top)Confirm a flow method.
Confirms to the peer that a flow command was received and processed.
bit active
Confirms the setting of the processed flow method: 1 means the peer will start sending or continue to send content frames; 0 means it will not.
(back to top)Request a channel close.
This method indicates that the sender wants to close the channel. This may be due to internal conditions (e.g. a forced shut-down) or due to an error handling a specific method, i.e. an exception. When a close is due to an exception, the sender provides the class and method id of the method which caused the exception.
reply-code reply-code
reply-text reply-text
class-id class-id
When the close is provoked by a method exception, this is the class of the method.
method-id method-id
When the close is provoked by a method exception, this is the ID of the method.
(back to top)Confirm a channel close.
This method confirms a Channel.Close method and tells the recipient that it is safe to release resources for the channel.
Work with exchanges.
Exchanges match and distribute messages across queues. Exchanges can be configured in the server or declared at runtime.
Class Grammar:
exchange = C:DECLARE S:DECLARE-OK / C:DELETE S:DELETE-OK / C:BIND S:BIND-OK / C:UNBIND S:UNBIND-OK
Verify exchange exists, create if needed.
This method creates an exchange if it does not already exist, and if the exchange exists, verifies that it is of the correct and expected class.
short reserved-1
exchange-name exchange
shortstr type
Each exchange belongs to one of a set of exchange types implemented by the server. The exchange types define the functionality of the exchange - i.e. how messages are routed through it. It is not valid or meaningful to attempt to change the type of an existing exchange.
bit passive
If set, the server will reply with Declare-Ok if the exchange already exists with the same name, and raise an error if not. The client can use this to check whether an exchange exists without modifying the server state. When set, all other method fields except name and no-wait are ignored. A declare with both passive and no-wait has no effect. Arguments are compared for semantic equivalence.
bit durable
If set when creating a new exchange, the exchange will be marked as durable. Durable exchanges remain active when a server restarts. Non-durable exchanges (transient exchanges) are purged if/when a server restarts.
bit auto-delete
If set, the exchange is deleted when all queues have finished using it.
bit internal
If set, the exchange may not be used directly by publishers, but only when bound to other exchanges. Internal exchanges are used to construct wiring that is not visible to applications.
no-wait no-wait
table arguments
A set of arguments for the declaration. The syntax and semantics of these arguments depends on the server implementation.
(back to top)Confirm exchange declaration.
This method confirms a Declare method and confirms the name of the exchange, essential for automatically-named exchanges.
(back to top)Delete an exchange.
This method deletes an exchange. When an exchange is deleted all queue bindings on the exchange are cancelled.
short reserved-1
exchange-name exchange
bit if-unused
If set, the server will only delete the exchange if it has no queue bindings. If the exchange has queue bindings the server does not delete it but raises a channel exception instead.
no-wait no-wait
(back to top)Confirm deletion of an exchange.
This method confirms the deletion of an exchange.
(back to top)Bind exchange to an exchange.
This method binds an exchange to an exchange.
short reserved-1
exchange-name destination
Specifies the name of the destination exchange to bind.
exchange-name source
Specifies the name of the source exchange to bind.
shortstr routing-key
Specifies the routing key for the binding. The routing key is used for routing messages depending on the exchange configuration. Not all exchanges use a routing key - refer to the specific exchange documentation.
no-wait no-wait
table arguments
A set of arguments for the binding. The syntax and semantics of these arguments depends on the exchange class.
(back to top)Confirm bind successful.
This method confirms that the bind was successful.
(back to top)Unbind an exchange from an exchange.
This method unbinds an exchange from an exchange.
short reserved-1
exchange-name destination
Specifies the name of the destination exchange to unbind.
exchange-name source
Specifies the name of the source exchange to unbind.
shortstr routing-key
Specifies the routing key of the binding to unbind.
no-wait no-wait
table arguments
Specifies the arguments of the binding to unbind.
(back to top)Confirm unbind successful.
This method confirms that the unbind was successful.
(back to top)Work with queues.
Queues store and forward messages. Queues can be configured in the server or created at runtime. Queues must be attached to at least one exchange in order to receive messages from publishers.
Class Grammar:
queue = C:DECLARE S:DECLARE-OK / C:BIND S:BIND-OK / C:UNBIND S:UNBIND-OK / C:PURGE S:PURGE-OK / C:DELETE S:DELETE-OK
Declare queue, create if needed.
This method creates or checks a queue. When creating a new queue the client can specify various properties that control the durability of the queue and its contents, and the level of sharing for the queue.
short reserved-1
queue-name queue
bit passive
If set, the server will reply with Declare-Ok if the queue already exists with the same name, and raise an error if not. The client can use this to check whether a queue exists without modifying the server state. When set, all other method fields except name and no-wait are ignored. A declare with both passive and no-wait has no effect. Arguments are compared for semantic equivalence.
bit durable
If set when creating a new queue, the queue will be marked as durable. Durable queues remain active when a server restarts. Non-durable queues (transient queues) are purged if/when a server restarts. Note that durable queues do not necessarily hold persistent messages, although it does not make sense to send persistent messages to a transient queue.
bit exclusive
Exclusive queues may only be accessed by the current connection, and are deleted when that connection closes. Passive declaration of an exclusive queue by other connections are not allowed.
bit auto-delete
If set, the queue is deleted when all consumers have finished using it. The last consumer can be cancelled either explicitly or because its channel is closed. If there was no consumer ever on the queue, it won't be deleted. Applications can explicitly delete auto-delete queues using the Delete method as normal.
no-wait no-wait
table arguments
A set of arguments for the declaration. The syntax and semantics of these arguments depends on the server implementation.
(back to top)Confirms a queue definition.
This method confirms a Declare method and confirms the name of the queue, essential for automatically-named queues.
queue-name queue
Reports the name of the queue. If the server generated a queue name, this field contains that name.
message-count message-count
long consumer-count
Reports the number of active consumers for the queue. Note that consumers can suspend activity (Channel.Flow) in which case they do not appear in this count.
(back to top)Bind queue to an exchange.
This method binds a queue to an exchange. Until a queue is bound it will not receive any messages. In a classic messaging model, store-and-forward queues are bound to a direct exchange and subscription queues are bound to a topic exchange.
short reserved-1
queue-name queue
Specifies the name of the queue to bind.
exchange-name exchange
Name of the exchange to bind to.
shortstr routing-key
Specifies the routing key for the binding. The routing key is used for routing messages depending on the exchange configuration. Not all exchanges use a routing key - refer to the specific exchange documentation. If the queue name is empty, the server uses the last queue declared on the channel. If the routing key is also empty, the server uses this queue name for the routing key as well. If the queue name is provided but the routing key is empty, the server does the binding with that empty routing key. The meaning of empty routing keys depends on the exchange implementation.
no-wait no-wait
table arguments
A set of arguments for the binding. The syntax and semantics of these arguments depends on the exchange class.
(back to top)Confirm bind successful.
This method confirms that the bind was successful.
(back to top)Unbind a queue from an exchange.
This method unbinds a queue from an exchange.
short reserved-1
queue-name queue
Specifies the name of the queue to unbind.
exchange-name exchange
The name of the exchange to unbind from.
shortstr routing-key
Specifies the routing key of the binding to unbind.
table arguments
Specifies the arguments of the binding to unbind.
(back to top)Confirm unbind successful.
This method confirms that the unbind was successful.
(back to top)Purge a queue.
This method removes all messages from a queue which are not awaiting acknowledgment.
short reserved-1
queue-name queue
Specifies the name of the queue to purge.
no-wait no-wait
(back to top)Confirms a queue purge.
This method confirms the purge of a queue.
message-count message-count
Reports the number of messages purged.
(back to top)Delete a queue.
This method deletes a queue. When a queue is deleted any pending messages are sent to a dead-letter queue if this is defined in the server configuration, and all consumers on the queue are cancelled.
short reserved-1
queue-name queue
Specifies the name of the queue to delete.
bit if-unused
If set, the server will only delete the queue if it has no consumers. If the queue has consumers the server does does not delete it but raises a channel exception instead.
bit if-empty
If set, the server will only delete the queue if it has no messages.
no-wait no-wait
(back to top)Confirm deletion of a queue.
This method confirms the deletion of a queue.
message-count message-count
Reports the number of messages deleted.
(back to top)Work with basic content.
The Basic class provides methods that support an industry-standard messaging model.
Class Grammar:
basic = C:QOS S:QOS-OK / C:CONSUME S:CONSUME-OK / C:CANCEL S:CANCEL-OK / C:PUBLISH content / S:RETURN content / S:DELIVER content / C:GET ( S:GET-OK content / S:GET-EMPTY ) / C:ACK / S:ACK / C:REJECT / C:NACK / S:NACK / C:RECOVER-ASYNC / C:RECOVER S:RECOVER-OK
Definition | Description |
---|---|
shortstr content-type | MIME content type. |
shortstr content-encoding | MIME content encoding. |
table headers | Message header field table. |
octet delivery-mode | Non-persistent (1) or persistent (2). |
octet priority | Message priority, 0 to 9. |
shortstr correlation-id | Application correlation identifier. |
shortstr reply-to | Address to reply to. |
shortstr expiration | Message expiration specification. |
shortstr message-id | Application message identifier. |
timestamp timestamp | Message timestamp. |
shortstr type | Message type name. |
shortstr user-id | Creating user id. |
shortstr app-id | Creating application id. |
shortstr reserved | Reserved, must be empty. |
Specify quality of service.
This method requests a specific quality of service. The QoS can be specified for the current channel or for all channels on the connection. The particular properties and semantics of a qos method always depend on the content class semantics. Though the qos method could in principle apply to both peers, it is currently meaningful only for the server.
long prefetch-size
The client can request that messages be sent in advance so that when the client finishes processing a message, the following message is already held locally, rather than needing to be sent down the channel. Prefetching gives a performance improvement. This field specifies the prefetch window size in octets. The server will send a message in advance if it is equal to or smaller in size than the available prefetch size (and also falls into other prefetch limits). May be set to zero, meaning "no specific limit", although other prefetch limits may still apply. The prefetch-size is ignored if the no-ack option is set.
short prefetch-count
Specifies a prefetch window in terms of whole messages. This field may be used in combination with the prefetch-size field; a message will only be sent in advance if both prefetch windows (and those at the channel and connection level) allow it. The prefetch-count is ignored if the no-ack option is set.
bit global
RabbitMQ has reinterpreted this field. The original specification said: "By default the QoS settings apply to the current channel only. If this field is set, they are applied to the entire connection." Instead, RabbitMQ takes global=false to mean that the QoS settings should apply per-consumer (for new consumers on the channel; existing ones being unaffected) and global=true to mean that the QoS settings should apply per-channel.
(back to top)Confirm the requested qos.
This method tells the client that the requested QoS levels could be handled by the server. The requested QoS applies to all active consumers until a new QoS is defined.
(back to top)Start a queue consumer.
This method asks the server to start a "consumer", which is a transient request for messages from a specific queue. Consumers last as long as the channel they were declared on, or until the client cancels them.
short reserved-1
queue-name queue
Specifies the name of the queue to consume from.
consumer-tag consumer-tag
Specifies the identifier for the consumer. The consumer tag is local to a channel, so two clients can use the same consumer tags. If this field is empty the server will generate a unique tag.
no-local no-local
no-ack no-ack
bit exclusive
Request exclusive consumer access, meaning only this consumer can access the queue.
no-wait no-wait
table arguments
A set of arguments for the consume. The syntax and semantics of these arguments depends on the server implementation.
(back to top)Confirm a new consumer.
The server provides the client with a consumer tag, which is used by the client for methods called on the consumer at a later stage.
consumer-tag consumer-tag
Holds the consumer tag specified by the client or provided by the server.
(back to top)End a queue consumer.
This method cancels a consumer. This does not affect already delivered messages, but it does mean the server will not send any more messages for that consumer. The client may receive an arbitrary number of messages in between sending the cancel method and receiving the cancel-ok reply. It may also be sent from the server to the client in the event of the consumer being unexpectedly cancelled (i.e. cancelled for any reason other than the server receiving the corresponding basic.cancel from the client). This allows clients to be notified of the loss of consumers due to events such as queue deletion. Note that as it is not a MUST for clients to accept this method from the server, it is advisable for the broker to be able to identify those clients that are capable of accepting the method, through some means of capability negotiation.
consumer-tag consumer-tag
no-wait no-wait
(back to top)Confirm a cancelled consumer.
This method confirms that the cancellation was completed.
consumer-tag consumer-tag
(back to top)Publish a message.
This method publishes a message to a specific exchange. The message will be routed to queues as defined by the exchange configuration and distributed to any active consumers when the transaction, if any, is committed.
short reserved-1
exchange-name exchange
Specifies the name of the exchange to publish to. The exchange name can be empty, meaning the default exchange. If the exchange name is specified, and that exchange does not exist, the server will raise a channel exception.
shortstr routing-key
Specifies the routing key for the message. The routing key is used for routing messages depending on the exchange configuration.
bit mandatory
This flag tells the server how to react if the message cannot be routed to a queue. If this flag is set, the server will return an unroutable message with a Return method. If this flag is zero, the server silently drops the message.
bit immediate
This flag tells the server how to react if the message cannot be routed to a queue consumer immediately. If this flag is set, the server will return an undeliverable message with a Return method. If this flag is zero, the server will queue the message, but with no guarantee that it will ever be consumed.
Return a failed message.
This method returns an undeliverable message that was published with the "immediate" flag set, or an unroutable message published with the "mandatory" flag set. The reply code and text provide information about the reason that the message was undeliverable.
reply-code reply-code
reply-text reply-text
exchange-name exchange
Specifies the name of the exchange that the message was originally published to. May be empty, meaning the default exchange.
shortstr routing-key
Specifies the routing key name specified when the message was published.
(back to top)Notify the client of a consumer message.
This method delivers a message to the client, via a consumer. In the asynchronous message delivery model, the client starts a consumer using the Consume method, then the server responds with Deliver methods as and when messages arrive for that consumer.
consumer-tag consumer-tag
delivery-tag delivery-tag
redelivered redelivered
exchange-name exchange
Specifies the name of the exchange that the message was originally published to. May be empty, indicating the default exchange.
shortstr routing-key
Specifies the routing key name specified when the message was published.
(back to top)Direct access to a queue.
This method provides a direct access to the messages in a queue using a synchronous dialogue that is designed for specific types of application where synchronous functionality is more important than performance.
short reserved-1
queue-name queue
Specifies the name of the queue to get a message from.
no-ack no-ack
(back to top)Provide client with a message.
This method delivers a message to the client following a get method. A message delivered by 'get-ok' must be acknowledged unless the no-ack option was set in the get method.
delivery-tag delivery-tag
redelivered redelivered
exchange-name exchange
Specifies the name of the exchange that the message was originally published to. If empty, the message was published to the default exchange.
shortstr routing-key
Specifies the routing key name specified when the message was published.
message-count message-count
(back to top)Indicate no messages available.
This method tells the client that the queue has no messages available for the client.
shortstr reserved-1
(back to top)Acknowledge one or more messages.
When sent by the client, this method acknowledges one or more messages delivered via the Deliver or Get-Ok methods. When sent by server, this method acknowledges one or more messages published with the Publish method on a channel in confirm mode. The acknowledgement can be for a single message or a set of messages up to and including a specific message.
delivery-tag delivery-tag
bit multiple
If set to 1, the delivery tag is treated as "up to and including", so that multiple messages can be acknowledged with a single method. If set to zero, the delivery tag refers to a single message. If the multiple field is 1, and the delivery tag is zero, this indicates acknowledgement of all outstanding messages.
Reject an incoming message.
This method allows a client to reject a message. It can be used to interrupt and cancel large incoming messages, or return untreatable messages to their original queue.
delivery-tag delivery-tag
bit requeue
If requeue is true, the server will attempt to requeue the message. If requeue is false or the requeue attempt fails the messages are discarded or dead-lettered.
Redeliver unacknowledged messages.
This method asks the server to redeliver all unacknowledged messages on a specified channel. Zero or more messages may be redelivered. This method is deprecated in favour of the synchronous Recover/Recover-Ok.
bit requeue
If this field is zero, the message will be redelivered to the original recipient. If this bit is 1, the server will attempt to requeue the message, potentially then delivering it to an alternative subscriber.
(back to top)Redeliver unacknowledged messages.
This method asks the server to redeliver all unacknowledged messages on a specified channel. Zero or more messages may be redelivered. This method replaces the asynchronous Recover.
bit requeue
If this field is zero, the message will be redelivered to the original recipient. If this bit is 1, the server will attempt to requeue the message, potentially then delivering it to an alternative subscriber.
(back to top)Confirm recovery.
This method acknowledges a Basic.Recover method.
(back to top)Reject one or more incoming messages.
This method allows a client to reject one or more incoming messages. It can be used to interrupt and cancel large incoming messages, or return untreatable messages to their original queue. This method is also used by the server to inform publishers on channels in confirm mode of unhandled messages. If a publisher receives this method, it probably needs to republish the offending messages.
delivery-tag delivery-tag
bit multiple
If set to 1, the delivery tag is treated as "up to and including", so that multiple messages can be rejected with a single method. If set to zero, the delivery tag refers to a single message. If the multiple field is 1, and the delivery tag is zero, this indicates rejection of all outstanding messages.
bit requeue
If requeue is true, the server will attempt to requeue the message. If requeue is false or the requeue attempt fails the messages are discarded or dead-lettered. Clients receiving the Nack methods should ignore this flag.
Work with transactions.
The Tx class allows publish and ack operations to be batched into atomic units of work. The intention is that all publish and ack requests issued within a transaction will complete successfully or none of them will. Servers SHOULD implement atomic transactions at least where all publish or ack requests affect a single queue. Transactions that cover multiple queues may be non-atomic, given that queues can be created and destroyed asynchronously, and such events do not form part of any transaction. Further, the behaviour of transactions with respect to the immediate and mandatory flags on Basic.Publish methods is not defined.
Class Grammar:
tx = C:SELECT S:SELECT-OK / C:COMMIT S:COMMIT-OK / C:ROLLBACK S:ROLLBACK-OK
Select standard transaction mode.
This method sets the channel to use standard transactions. The client must use this method at least once on a channel before using the Commit or Rollback methods.
(back to top)Confirm transaction mode.
This method confirms to the client that the channel was successfully set to use standard transactions.
(back to top)Commit the current transaction.
This method commits all message publications and acknowledgments performed in the current transaction. A new transaction starts immediately after a commit.
Confirm a successful commit.
This method confirms to the client that the commit succeeded. Note that if a commit fails, the server raises a channel exception.
(back to top)Abandon the current transaction.
This method abandons all message publications and acknowledgments performed in the current transaction. A new transaction starts immediately after a rollback. Note that unacked messages will not be automatically redelivered by rollback; if that is required an explicit recover call should be issued.
Confirm successful rollback.
This method confirms to the client that the rollback succeeded. Note that if an rollback fails, the server raises a channel exception.
(back to top)Work with confirms.
The Confirm class allows publishers to put the channel in confirm mode and subsequently be notified when messages have been handled by the broker. The intention is that all messages published on a channel in confirm mode will be acknowledged at some point. By acknowledging a message the broker assumes responsibility for it and indicates that it has done something it deems reasonable with it. Unroutable mandatory or immediate messages are acknowledged right after the Basic.Return method. Messages are acknowledged when all queues to which the message has been routed have either delivered the message and received an acknowledgement (if required), or enqueued the message (and persisted it if required). Published messages are assigned ascending sequence numbers, starting at 1 with the first Confirm.Select method. The server confirms messages by sending Basic.Ack methods referring to these sequence numbers.
Class Grammar:
confirm = C:SELECT S:SELECT-OK
.
This method sets the channel to use publisher acknowledgements. The client can only use this method on a non-transactional channel.
no-wait nowait
(back to top).
This method confirms to the client that the channel was successfully set to use publisher acknowledgements.
(back to top)The following domains are defined in the specification:
Name | Type | Description |
---|---|---|
bit | bit | [single bit] |
class-id | short | |
consumer-tag | shortstr | Identifier for the consumer, valid within the current channel. |
delivery-tag | longlong |
The server-assigned and channel-specific delivery tag
|
exchange-name | shortstr | The exchange name is a client-selected string that identifies the exchange for publish methods. |
long | long | [32-bit integer] |
longlong | longlong | [64-bit integer] |
longstr | longstr | [long string] |
message-count | long | The number of messages in the queue, which will be zero for newly-declared queues. This is the number of messages present in the queue, and committed if the channel on which they were published is transacted, that are not waiting acknowledgement. |
method-id | short | |
no-ack | bit | If this field is set the server does not expect acknowledgements for messages. That is, when a message is delivered to the client the server assumes the delivery will succeed and immediately dequeues it. This functionality may increase performance but at the cost of reliability. Messages can get lost if a client dies before they are delivered to the application. |
no-local | bit | If the no-local field is set the server will not send messages to the connection that published them. |
no-wait | bit | If set, the server will not respond to the method. The client should not wait for a reply method. If the server could not complete the method it will raise a channel or connection exception. |
octet | octet | [single octet] |
path | shortstr | Unconstrained. |
peer-properties | table | This table provides a set of peer properties, used for identification, debugging, and general information. |
queue-name | shortstr | The queue name identifies the queue within the vhost. In methods where the queue name may be blank, and that has no specific significance, this refers to the 'current' queue for the channel, meaning the last queue that the client declared on the channel. If the client did not declare a queue, and the method needs a queue name, this will result in a 502 (syntax error) channel exception. |
redelivered | bit |
This indicates that the message has been previously delivered to this or
another client.
|
reply-code | short | The reply code. The AMQ reply codes are defined as constants at the start of this formal specification. |
reply-text | shortstr | The localised reply text. This text can be logged as an aid to resolving issues. |
short | short | [16-bit integer] |
shortstr | shortstr | [short string (max. 256 characters)] |
table | table | [field table] |
timestamp | timestamp | [64-bit timestamp] |
Many constants are error codes. Where this is so, they fall into one of two categories:
The following constants are defined in the specification:
Name | Value | Error Class | Description |
---|---|---|---|
frame-method | 1 | ||
frame-header | 2 | ||
frame-body | 3 | ||
frame-heartbeat | 8 | ||
frame-min-size | 4096 | ||
frame-end | 206 | ||
reply-success | 200 | Indicates that the method completed successfully. This reply code is reserved for future use - the current protocol design does not use positive confirmation and reply codes are sent only in case of an error. | |
content-too-large | 311 | channel | The client attempted to transfer content larger than the server could accept at the present time. The client may retry at a later time. |
no-route | 312 | channel | Returned when RabbitMQ sends back with 'basic.return' when a 'mandatory' message cannot be delivered to any queue. |
no-consumers | 313 | channel | When the exchange cannot deliver to a consumer when the immediate flag is set. As a result of pending data on the queue or the absence of any consumers of the queue. |
connection-forced | 320 | connection | An operator intervened to close the connection for some reason. The client may retry at some later date. |
invalid-path | 402 | connection | The client tried to work with an unknown virtual host. |
access-refused | 403 | channel | The client attempted to work with a server entity to which it has no access due to security settings. |
not-found | 404 | channel | The client attempted to work with a server entity that does not exist. |
resource-locked | 405 | channel | The client attempted to work with a server entity to which it has no access because another client is working with it. |
precondition-failed | 406 | channel | The client requested a method that was not allowed because some precondition failed. |
frame-error | 501 | connection | The sender sent a malformed frame that the recipient could not decode. This strongly implies a programming error in the sending peer. |
syntax-error | 502 | connection | The sender sent a frame that contained illegal values for one or more fields. This strongly implies a programming error in the sending peer. |
command-invalid | 503 | connection | The client sent an invalid sequence of frames, attempting to perform an operation that was considered invalid by the server. This usually implies a programming error in the client. |
channel-error | 504 | connection | The client attempted to work with a channel that had not been correctly opened. This most likely indicates a fault in the client layer. |
unexpected-frame | 505 | connection | The peer sent a frame that was not expected, usually in the context of a content header and body. This strongly indicates a fault in the peer's content processing. |
resource-error | 506 | connection | The server could not complete the method because it lacked sufficient resources. This may be due to the client creating too many of some type of entity. |
not-allowed | 530 | connection | The client tried to work with some entity in a manner that is prohibited by the server, due to security settings or by some other criteria. |
not-implemented | 540 | connection | The client tried to use functionality that is not implemented in the server. |
internal-error | 541 | connection | The server could not complete the method because of an internal error. The server may require intervention by an operator in order to resume normal operations. |
If you have questions about the contents of this guide or any other topic related to RabbitMQ, don't hesitate to ask them on the RabbitMQ mailing list.
If you'd like to contribute an improvement to the site, its source is available on GitHub. Simply fork the repository and submit a pull request. Thank you!