pamqp.commands
The classes inside pamqp.commands
allow for the automatic marshaling
and unmarshaling of AMQP method frames and
Basic.Properties
. In addition the
command classes contain information that designates if they are synchronous
commands and if so, what the expected responses are. Each commands arguments
are detailed in the class and are listed in the attributes property.
Note
All AMQ classes and methods extend pamqp.base.Frame
.
- class pamqp.commands.Connection[source]
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 Start(version_major: int = 0, version_minor: int = 9, server_properties: Dict[str, FieldValue] | None = None, mechanisms: str = 'PLAIN', locales: str = 'en_US')[source]
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.
- Parameters:
version_major – Protocol major version - Default:
0
version_minor – Protocol minor version - Default:
9
server_properties (
FieldTable
) – Server properties - Default:{}
mechanisms – Available security mechanisms - Default:
PLAIN
locales – Available message locales - Default:
en_US
- class StartOk(client_properties: Dict[str, FieldValue] | None = None, mechanism: str = 'PLAIN', response: str = '', locale: str = 'en_US')[source]
Select security mechanism and locale
This method selects a SASL security mechanism.
- Parameters:
client_properties (
FieldTable
) – Client properties - Default:{}
mechanism – Selected security mechanism - Default:
PLAIN
response – Security response data - Default:
''
locale – Selected message locale - Default:
en_US
- class Secure(challenge: str | None = None)[source]
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.
- Parameters:
challenge – Security challenge data
- class SecureOk(response: str | None = None)[source]
Security mechanism response
This method attempts to authenticate, passing a block of SASL data for the security mechanism at the server side.
- Parameters:
response – Security response data
- class Tune(channel_max: int = 0, frame_max: int = 0, heartbeat: int = 0)[source]
Propose connection tuning parameters
This method proposes a set of connection configuration values to the client. The client can accept and/or adjust these.
- Parameters:
channel_max – Proposed maximum channels - Default:
0
frame_max – Proposed maximum frame size - Default:
0
heartbeat – Desired heartbeat delay - Default:
0
- class TuneOk(channel_max: int = 0, frame_max: int = 0, heartbeat: int = 0)[source]
Negotiate connection tuning parameters
This method sends the client’s connection tuning parameters to the server. Certain fields are negotiated, others provide capability information.
- Parameters:
channel_max – Negotiated maximum channels - Default:
0
frame_max – Negotiated maximum frame size - Default:
0
heartbeat – Desired heartbeat delay - Default:
0
- class Open(virtual_host: str = '/', capabilities: str = '', insist: bool = False)[source]
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.
- Parameters:
virtual_host – Virtual host name - Default:
/
capabilities – Deprecated, must be empty - Default:
''
insist – Deprecated, must be
False
- Default:False
- Raises:
ValueError – when an argument fails to validate
- __init__(virtual_host: str = '/', capabilities: str = '', insist: bool = False) None [source]
Initialize the
Connection.Open
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class OpenOk(known_hosts: str = '')[source]
Signal that connection is ready
This method signals to the client that the connection is ready for use.
- Parameters:
known_hosts – Deprecated, must be empty - Default:
''
- __init__(known_hosts: str = '') None [source]
Initialize the
Connection.OpenOk
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class Close(reply_code: int | None = None, reply_text: str = '', class_id: int | None = None, method_id: int | None = None)[source]
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.
- Parameters:
reply_code – Reply code from server
reply_text – Localised reply text - Default:
''
class_id – Failing method class
method_id – Failing method ID
- class CloseOk[source]
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.
- class Blocked(reason: str = '')[source]
Indicate that connection is blocked
This method indicates that a connection has been blocked and does not accept new publishes.
- Parameters:
reason – Block reason - Default:
''
- __init__(reason: str = '') None [source]
Initialize the
Connection.Blocked
class
- class Unblocked[source]
Indicate that connection is unblocked
This method indicates that a connection has been unblocked and now accepts publishes.
- class UpdateSecret(new_secret: str | None = None, reason: str | None = None)[source]
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.
- Parameters:
new_secret – New secret
reason – Reason
- class pamqp.commands.Channel[source]
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 Open(out_of_band: str = '0')[source]
Open a channel for use
This method opens a channel to the server.
- Parameters:
out_of_band – Protocol level field, do not use, must be
0
. - Default:0
- __init__(out_of_band: str = '0') None [source]
Initialize the
Channel.Open
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class OpenOk(channel_id: str = '0')[source]
Signal that the channel is ready
This method signals to the client that the channel is ready for use.
- Parameters:
channel_id – Deprecated, must be
0
- Default:0
- __init__(channel_id: str = '0') None [source]
Initialize the
Channel.OpenOk
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class Flow(active: bool | None = None)[source]
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.GetOk
methods.- Parameters:
active – Start/stop content frames
- class FlowOk(active: bool | None = None)[source]
Confirm a flow method
Confirms to the peer that a flow command was received and processed.
- Parameters:
active – Current flow setting
- class Close(reply_code: int | None = None, reply_text: str = '', class_id: int | None = None, method_id: int | None = None)[source]
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.
- Parameters:
reply_code – Reply code from server
reply_text – Localised reply text - Default:
''
class_id – Failing method class
method_id – Failing method ID
- class CloseOk[source]
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.
- class pamqp.commands.Exchange[source]
Work with exchanges
Exchanges match and distribute messages across queues. Exchanges can be configured in the server or declared at runtime.
- class Declare(ticket: int = 0, exchange: str = '', exchange_type: str = 'direct', passive: bool = False, durable: bool = False, auto_delete: bool = False, internal: bool = False, nowait: bool = False, arguments: Dict[str, FieldValue] | None = None)[source]
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.
Note
The AMQP type argument is referred to as “exchange_type” to not conflict with the Python type keyword.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
exchange – exchange name - Default:
''
exchange_type – Exchange type - Default:
direct
passive – Do not create exchange - Default:
False
durable – Request a durable exchange - Default:
False
auto_delete – Auto-delete when unused - Default:
False
internal – Create internal exchange - Default:
False
nowait – Do not send a reply method - Default:
False
arguments (
Arguments
) – Arguments for declaration - Default:{}
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, exchange: str = '', exchange_type: str = 'direct', passive: bool = False, durable: bool = False, auto_delete: bool = False, internal: bool = False, nowait: bool = False, arguments: Dict[str, FieldValue] | None = None) None [source]
Initialize the
Exchange.Declare
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class DeclareOk[source]
Confirm exchange declaration
This method confirms a Declare method and confirms the name of the exchange, essential for automatically-named exchanges.
- class Delete(ticket: int = 0, exchange: str = '', if_unused: bool = False, nowait: bool = False)[source]
Delete an exchange
This method deletes an exchange. When an exchange is deleted all queue bindings on the exchange are cancelled.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
exchange – exchange name - Default:
''
if_unused – Delete only if unused - Default:
False
nowait – Do not send a reply method - Default:
False
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, exchange: str = '', if_unused: bool = False, nowait: bool = False) None [source]
Initialize the
Exchange.Delete
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class DeleteOk[source]
Confirm deletion of an exchange
This method confirms the deletion of an exchange.
- class Bind(ticket: int = 0, destination: str = '', source: str = '', routing_key: str = '', nowait: bool = False, arguments: Dict[str, FieldValue] | None = None)[source]
Bind exchange to an exchange
This method binds an exchange to an exchange.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
destination – Name of the destination exchange to bind to - Default:
''
source – Name of the source exchange to bind to - Default:
''
routing_key – Message routing key - Default:
''
nowait – Do not send a reply method - Default:
False
arguments (
Arguments
) – Arguments for binding - Default:{}
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, destination: str = '', source: str = '', routing_key: str = '', nowait: bool = False, arguments: Dict[str, FieldValue] | None = None) None [source]
Initialize the
Exchange.Bind
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class Unbind(ticket: int = 0, destination: str = '', source: str = '', routing_key: str = '', nowait: bool = False, arguments: Dict[str, FieldValue] | None = None)[source]
Unbind an exchange from an exchange
This method unbinds an exchange from an exchange.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
destination – Specifies the name of the destination exchange to unbind. - Default:
''
source – Specifies the name of the source exchange to unbind. - Default:
''
routing_key – Routing key of binding - Default:
''
nowait – Do not send a reply method - Default:
False
arguments (
Arguments
) – Arguments of binding - Default:{}
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, destination: str = '', source: str = '', routing_key: str = '', nowait: bool = False, arguments: Dict[str, FieldValue] | None = None) None [source]
Initialize the
Exchange.Unbind
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class pamqp.commands.Queue[source]
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 Declare(ticket: int = 0, queue: str = '', passive: bool = False, durable: bool = False, exclusive: bool = False, auto_delete: bool = False, nowait: bool = False, arguments: Dict[str, FieldValue] | None = None)[source]
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.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
queue – queue name - Default:
''
passive – Do not create queue - Default:
False
durable – Request a durable queue - Default:
False
exclusive – Request an exclusive queue - Default:
False
auto_delete – Auto-delete queue when unused - Default:
False
nowait – Do not send a reply method - Default:
False
arguments (
Arguments
) – Arguments for declaration - Default:{}
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, queue: str = '', passive: bool = False, durable: bool = False, exclusive: bool = False, auto_delete: bool = False, nowait: bool = False, arguments: Dict[str, FieldValue] | None = None) None [source]
Initialize the
Queue.Declare
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class DeclareOk(queue: str | None = None, message_count: int | None = None, consumer_count: int | None = None)[source]
Confirms a queue definition
This method confirms a Declare method and confirms the name of the queue, essential for automatically-named queues.
- Parameters:
queue – Reports the name of the queue. If the server generated a queue name, this field contains that name.
message_count – Number of messages in the queue.
consumer_count – Number of consumers
- Raises:
ValueError – when an argument fails to validate
- __init__(queue: str | None = None, message_count: int | None = None, consumer_count: int | None = None) None [source]
Initialize the
Queue.DeclareOk
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class Bind(ticket: int = 0, queue: str = '', exchange: str = '', routing_key: str = '', nowait: bool = False, arguments: Dict[str, FieldValue] | None = None)[source]
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.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
queue – Specifies the name of the queue to bind. - Default:
''
exchange – Name of the exchange to bind to - Default:
''
routing_key – Message routing key - Default:
''
nowait – Do not send a reply method - Default:
False
arguments (
Arguments
) – Arguments for binding - Default:{}
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, queue: str = '', exchange: str = '', routing_key: str = '', nowait: bool = False, arguments: Dict[str, FieldValue] | None = None) None [source]
Initialize the
Queue.Bind
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class Purge(ticket: int = 0, queue: str = '', nowait: bool = False)[source]
Purge a queue
This method removes all messages from a queue which are not awaiting acknowledgment.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
queue – Specifies the name of the queue to purge. - Default:
''
nowait – Do not send a reply method - Default:
False
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, queue: str = '', nowait: bool = False) None [source]
Initialize the
Queue.Purge
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class PurgeOk(message_count: int | None = None)[source]
Confirms a queue purge
This method confirms the purge of a queue.
- Parameters:
message_count – Reports the number of messages purged.
- class Delete(ticket: int = 0, queue: str = '', if_unused: bool = False, if_empty: bool = False, nowait: bool = False)[source]
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.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
queue – Specifies the name of the queue to delete. - Default:
''
if_unused – Delete only if unused - Default:
False
if_empty – Delete only if empty - Default:
False
nowait – Do not send a reply method - Default:
False
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, queue: str = '', if_unused: bool = False, if_empty: bool = False, nowait: bool = False) None [source]
Initialize the
Queue.Delete
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class DeleteOk(message_count: int | None = None)[source]
Confirm deletion of a queue
This method confirms the deletion of a queue.
- Parameters:
message_count – Reports the number of messages deleted.
- class Unbind(ticket: int = 0, queue: str = '', exchange: str = '', routing_key: str = '', arguments: Dict[str, FieldValue] | None = None)[source]
Unbind a queue from an exchange
This method unbinds a queue from an exchange.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
queue – Specifies the name of the queue to unbind. - Default:
''
exchange – The name of the exchange to unbind from. - Default:
''
routing_key – Routing key of binding - Default:
''
arguments (
Arguments
) – Arguments of binding - Default:{}
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, queue: str = '', exchange: str = '', routing_key: str = '', arguments: Dict[str, FieldValue] | None = None) None [source]
Initialize the
Queue.Unbind
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class pamqp.commands.Basic[source]
Work with basic content
The Basic class provides methods that support an industry-standard messaging model.
- class Qos(prefetch_size: int = 0, prefetch_count: int = 0, global_: bool = False)[source]
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.
- Parameters:
prefetch_size – Prefetch window in octets - Default:
0
prefetch_count – Prefetch window in messages - Default:
0
global – Apply to entire connection - Default:
False
- class QosOk[source]
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.
- class Consume(ticket: int = 0, queue: str = '', consumer_tag: str = '', no_local: bool = False, no_ack: bool = False, exclusive: bool = False, nowait: bool = False, arguments: Dict[str, FieldValue] | None = None)[source]
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.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
queue – Specifies the name of the queue to consume from. - Default:
''
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. - Default:
''
no_local – Do not deliver own messages - Default:
False
no_ack – No acknowledgement needed - Default:
False
exclusive – Request exclusive access - Default:
False
nowait – Do not send a reply method - Default:
False
arguments (
Arguments
) – Arguments for declaration - Default:{}
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, queue: str = '', consumer_tag: str = '', no_local: bool = False, no_ack: bool = False, exclusive: bool = False, nowait: bool = False, arguments: Dict[str, FieldValue] | None = None) None [source]
Initialize the
Basic.Consume
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class ConsumeOk(consumer_tag: str | None = None)[source]
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.
- Parameters:
consumer_tag – Holds the consumer tag specified by the client or provided by the server.
- class Cancel(consumer_tag: str | None = None, nowait: bool = False)[source]
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.
- Parameters:
consumer_tag – Consumer tag
nowait – Do not send a reply method - Default:
False
- class CancelOk(consumer_tag: str | None = None)[source]
Confirm a cancelled consumer
This method confirms that the cancellation was completed.
- Parameters:
consumer_tag – Consumer tag
- class Publish(ticket: int = 0, exchange: str = '', routing_key: str = '', mandatory: bool = False, immediate: bool = False)[source]
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.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
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. - Default:
''
routing_key – Message routing key - Default:
''
mandatory – Indicate mandatory routing - Default:
False
immediate – Request immediate delivery - Default:
False
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, exchange: str = '', routing_key: str = '', mandatory: bool = False, immediate: bool = False) None [source]
Initialize the
Basic.Publish
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class Return(reply_code: int | None = None, reply_text: str = '', exchange: str = '', routing_key: str | None = None)[source]
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.
- Parameters:
reply_code – Reply code from server
reply_text – Localised reply text - Default:
''
exchange – Specifies the name of the exchange that the message was originally published to. May be empty, meaning the default exchange. - Default:
''
routing_key – Message routing key
- Raises:
ValueError – when an argument fails to validate
- __init__(reply_code: int | None = None, reply_text: str = '', exchange: str = '', routing_key: str | None = None) None [source]
Initialize the
Basic.Return
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class Deliver(consumer_tag: str | None = None, delivery_tag: int | None = None, redelivered: bool = False, exchange: str = '', routing_key: str | None = None)[source]
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.
- Parameters:
consumer_tag – Consumer tag
delivery_tag – Server-assigned delivery tag
redelivered – Message is being redelivered - Default:
False
exchange – Specifies the name of the exchange that the message was originally published to. May be empty, indicating the default exchange. - Default:
''
routing_key – Message routing key
- Raises:
ValueError – when an argument fails to validate
- __init__(consumer_tag: str | None = None, delivery_tag: int | None = None, redelivered: bool = False, exchange: str = '', routing_key: str | None = None) None [source]
Initialize the
Basic.Deliver
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class Get(ticket: int = 0, queue: str = '', no_ack: bool = False)[source]
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.
- Parameters:
ticket – Deprecated, must be
0
- Default:0
queue – Specifies the name of the queue to get a message from. - Default:
''
no_ack – No acknowledgement needed - Default:
False
- Raises:
ValueError – when an argument fails to validate
- __init__(ticket: int = 0, queue: str = '', no_ack: bool = False) None [source]
Initialize the
Basic.Get
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class GetOk(delivery_tag: int | None = None, redelivered: bool = False, exchange: str = '', routing_key: str | None = None, message_count: int | None = None)[source]
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.
- Parameters:
delivery_tag – Server-assigned delivery tag
redelivered – Message is being redelivered - Default:
False
exchange – Specifies the name of the exchange that the message was originally published to. If empty, the message was published to the default exchange. - Default:
''
routing_key – Message routing key
message_count – Number of messages in the queue.
- Raises:
ValueError – when an argument fails to validate
- __init__(delivery_tag: int | None = None, redelivered: bool = False, exchange: str = '', routing_key: str | None = None, message_count: int | None = None) None [source]
Initialize the
Basic.GetOk
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class GetEmpty(cluster_id: str = '')[source]
Indicate no messages available
This method tells the client that the queue has no messages available for the client.
- Parameters:
cluster_id – Deprecated, must be empty - Default:
''
- __init__(cluster_id: str = '') None [source]
Initialize the
Basic.GetEmpty
class
- validate() None [source]
Validate the frame data ensuring all domains or attributes adhere to the protocol specification.
- Raises:
ValueError – on validation error
- class Ack(delivery_tag: int = 0, multiple: bool = False)[source]
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.
- Parameters:
delivery_tag – Server-assigned delivery tag - Default:
0
multiple – Acknowledge multiple messages - Default:
False
- class Reject(delivery_tag: int | None = None, requeue: bool = True)[source]
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.
- Parameters:
delivery_tag – Server-assigned delivery tag
requeue – Requeue the message - Default:
True
- class RecoverAsync(requeue: bool = False)[source]
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.
Deprecated since version This: command is deprecated in AMQP 0-9-1
- Parameters:
requeue – Requeue the message - Default:
False
- __init__(requeue: bool = False) None [source]
Initialize the
Basic.RecoverAsync
class
- class Recover(requeue: bool = False)[source]
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.
- Parameters:
requeue – Requeue the message - Default:
False
- __init__(requeue: bool = False) None [source]
Initialize the
Basic.Recover
class
- class RecoverOk[source]
Confirm recovery
This method acknowledges a
Basic.Recover
method.
- class Nack(delivery_tag: int = 0, multiple: bool = False, requeue: bool = True)[source]
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.
- Parameters:
delivery_tag – Server-assigned delivery tag - Default:
0
multiple – Reject multiple messages - Default:
False
requeue – Requeue the message - Default:
True
- class Properties(content_type: str | None = None, content_encoding: str | None = None, headers: Dict[str, FieldValue] | None = None, delivery_mode: int | None = None, priority: int | None = None, correlation_id: str | None = None, reply_to: str | None = None, expiration: str | None = None, message_id: str | None = None, timestamp: datetime | None = None, message_type: str | None = None, user_id: str | None = None, app_id: str | None = None, cluster_id: str = '')[source]
Content Properties
Note
The AMQP property type is named
message_type
as to not conflict with the Pythontype
keyword- Parameters:
content_type – MIME content type
content_encoding – MIME content encoding
headers (typing.Optional[
FieldTable
]) – Message header field tabledelivery_mode – Non-persistent (1) or persistent (2)
priority – Message priority, 0 to 9
correlation_id – Application correlation identifier
reply_to – Address to reply to
expiration – Message expiration specification
message_id – Application message identifier
timestamp – Message timestamp
message_type – Message type name
user_id – Creating user id
app_id – Creating application id
cluster_id – Deprecated, must be empty
- Raises:
ValueError
- __init__(content_type: str | None = None, content_encoding: str | None = None, headers: Dict[str, FieldValue] | None = None, delivery_mode: int | None = None, priority: int | None = None, correlation_id: str | None = None, reply_to: str | None = None, expiration: str | None = None, message_id: str | None = None, timestamp: datetime | None = None, message_type: str | None = None, user_id: str | None = None, app_id: str | None = None, cluster_id: str = '') None [source]
Initialize the Basic.Properties class
- class pamqp.commands.Tx[source]
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 Select[source]
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.
- class SelectOk[source]
Confirm transaction mode
This method confirms to the client that the channel was successfully set to use standard transactions.
- class Commit[source]
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.
- class CommitOk[source]
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.
- class Rollback[source]
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.
- class pamqp.commands.Confirm[source]
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 firstConfirm.Select
method. The server confirms messages by sendingBasic.Ack
methods referring to these sequence numbers.- class Select(nowait: bool = False)[source]
Select confirm mode (i.e. enable publisher acknowledgements)
This method sets the channel to use publisher acknowledgements. The client can only use this method on a non-transactional channel.
- Parameters:
nowait – Do not send a reply method - Default:
False
- __init__(nowait: bool = False) None [source]
Initialize the
Confirm.Select
class