The Channel class provides a wrapper for interacting with RabbitMQ implementing the methods and behaviors for an AMQP Channel.
A Channel is the primary communication method for interacting with RabbitMQ. It is recommended that you do not directly invoke the creation of a channel object in your application code but rather construct the a channel by calling the active connection’s channel() method.
Pass in a callback handler and a list replies from the RabbitMQ broker which you’d like the callback notified of. Callbacks should allow for the frame parameter to be passed in.
Parameters: |
|
---|
Pass a callback function that will be called when the basic_cancel is sent by the server. The callback function should receive a frame parameter.
Parameters: | callback (method) – The method to call on callback |
---|
Pass a callback function that will be called when the channel is closed. The callback function will receive the channel, the reply_code (int) and the reply_text (int) sent by the server describing why the channel was closed.
Parameters: | callback (method) – The method to call on callback |
---|
Pass a callback function that will be called when Channel.Flow is called by the remote server. Note that newer versions of RabbitMQ will not issue this but instead use TCP backpressure
Parameters: | callback (method) – The method to call on callback |
---|
Pass a callback function that will be called when basic_publish as sent a message that has been rejected and returned by the server.
Parameters: | callback (method) – The method to call on callback with the signature callback(channel, method, properties,
channel: pika.Channel method: pika.spec.Basic.Return properties: pika.spec.BasicProperties body: str, unicode, or bytes (python 3.x) |
---|
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: |
|
---|
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.
Parameters: |
|
---|---|
Raises : | ValueError |
Sends the AMQP command Basic.Consume to the broker and binds messages for the consumer_tag to the consumer callback. If you do not pass in a consumer_tag, one will be automatically generated for you. Returns the consumer tag.
For more information on basic_consume, see: http://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.consume
Parameters: |
|
---|---|
Return type: | str |
Get a single message from the AMQP broker. If you want to be notified of Basic.GetEmpty, use the Channel.add_callback method adding your Basic.GetEmpty callback which should expect only one parameter, frame. For more information on basic_get and its parameters, see:
http://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.get
Parameters: |
|
---|
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.
Parameters: |
|
---|
Publish to the channel with the given exchange, routing key and body. For more information on basic_publish and what the parameters do, see:
http://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.publish
Parameters: |
|
---|
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 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.
Parameters: |
|
---|
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: |
|
---|
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: |
|
---|---|
Raises : | TypeError |
Will invoke a clean shutdown of the channel with the AMQP Broker.
Parameters: |
|
---|
Turn on Confirm mode in the channel. Pass in a callback to be notified by the Broker when a message has been confirmed as received or rejected (Basic.Ack, Basic.Nack) from the broker to the publisher.
Parameters: |
|
---|
Property method that returns a list of currently active consumers
Return type: | list |
---|
Bind an exchange to another exchange.
Parameters: |
|
---|
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.
If passive set, the server will reply with Declare-Ok if the exchange already exists with the same name, and raise an error if not and if the exchange does not already exist, the server MUST raise a channel exception with reply code 404 (not found).
Parameters: |
|
---|
Delete the exchange.
Parameters: |
|
---|
Unbind an exchange from another exchange.
Parameters: |
|
---|
Turn Channel flow control off and on. Pass a callback to be notified of the response from the server. active is a bool. Callback should expect a bool in response indicating channel flow state. For more information, please reference:
http://www.rabbitmq.com/amqp-0-9-1-reference.html#channel.flow
Parameters: |
|
---|
Returns True if the channel is closed.
Return type: | bool |
---|
Returns True if the channel is closing.
Return type: | bool |
---|
Returns True if the channel is open.
Return type: | bool |
---|
Open the channel
Bind the queue to the specified exchange
Parameters: |
|
---|
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.
Leave the queue name empty for a auto-named queue in RabbitMQ
Parameters: |
|
---|
Delete a queue from the broker.
Parameters: |
|
---|
Purge all of the messages from the specified queue
Parameters: |
|
---|
Unbind a queue from an exchange.
Parameters: |
|
---|
Commit a transaction
Parameters: | callback (method) – The callback for delivery confirmations |
---|
Rollback a transaction.
Parameters: | callback (method) – The callback for delivery confirmations |
---|
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.
Parameters: | callback (method) – The callback for delivery confirmations |
---|