Connect to an AMQP server on the given host and port.
Log in to the given virtual host using the supplied credentials. This function is a coroutine.
Parameters: |
---|
Further keyword arguments are passed on to create_connection().
Returns: | the Connection object. |
---|
Manage connections to AMQP brokers.
A Connection is a long-lasting mode of communication with a remote server. Each connection occupies a single TCP connection, and may carry multiple Channels. A connection communicates with a single virtual host on the server; virtual hosts are sandboxed and may not communicate with one another.
Applications are advised to use one connection for each AMQP peer it needs to communicate with; if you need to perform multiple concurrent tasks you should open multiple channels.
Connections are created using asynqp.connect().
Manage AMQP Channels.
A Channel is a ‘virtual connection’ over which messages are sent and received. Several independent channels can be multiplexed over the same Connection, so peers can perform several tasks concurrently while using a single socket.
Channels are created using Connection.open_channel().
Declare an Exchange on the broker. If the exchange does not exist, it will be created.
This method is a coroutine.
Parameters: |
|
---|---|
Returns: | the new Exchange object. |
Declare a queue on the broker. If the queue does not exist, it will be created.
This method is a coroutine.
Parameters: |
|
---|---|
Returns: | The new Queue object. |
Manage AMQP Queues and consume messages.
A queue is a collection of messages, to which new messages can be delivered via an Exchange, and from which messages can be consumed by an application.
Queues are created using Channel.declare_queue().
the name of the queue
if True, the queue will be re-created when the broker restarts
if True, the queue is only accessible over one channel
if True, the queue will be deleted when its last consumer is removed
Bind a queue to an exchange, with the supplied routing key.
This action ‘subscribes’ the queue to the routing key; the precise meaning of this varies with the exchange type.
This method is a coroutine.
Parameters: |
|
---|---|
Returns: | The new QueueBinding object |
Start a consumer on the queue. Messages will be delivered asynchronously to the consumer. The callback function will be called whenever a new message arrives on the queue.
This method is a coroutine.
Parameters: |
|
---|---|
Returns: | The newly created Consumer object. |
Synchronously get a message from the queue.
This method is a coroutine.
Parameters: | no_ack (bool) – if true, the broker does not require acknowledgement of receipt of the message. |
---|---|
Returns: | an IncomingMessage, or None if there were no messages on the queue. |
Manage AMQP Exchanges and publish messages.
An exchange is a ‘routing node’ to which messages can be published. When a message is published to an exchange, the exchange determines which Queue to deliver the message to by inspecting the message’s routing key and the exchange’s bindings. You can bind a queue to an exchange, to start receiving messages on the queue, using Queue.bind.
Exchanges are created using Channel.declare_exchange().
the name of the exchange.
the type of the exchange (usually one of 'fanout', 'direct', 'topic', or 'headers').
Publish a message on the exchange, to be asynchronously delivered to queues.
Parameters: |
|
---|
Manage queue-exchange bindings.
Represents a binding between a Queue and an Exchange. Once a queue has been bound to an exchange, messages published to that exchange will be delivered to the queue. The delivery may be conditional, depending on the type of the exchange.
QueueBindings are created using Queue.bind().
the routing key used for the binding
Unbind the queue from the exchange. This method is a coroutine.
A consumer asynchronously recieves messages from a queue as they arrive.
Consumers are created using Queue.consume().
A string representing the consumer tag used by the server to identify this consumer.
The callback function that is called when messages are delivered to the consumer. This is the function that was passed to Queue.consume(), and should accept a single IncomingMessage argument.
Boolean. True if the consumer has been successfully cancelled.
Cancel the consumer and stop recieving messages.
An AMQP Basic message.
Some of the constructor parameters are ignored by the AMQP broker and are provided just for the convenience of user applications. They are marked “for applications” in the list below.
Parameters: |
|
---|
Attributes are the same as the constructor parameters.
Parse the message body as JSON.
Returns: | the parsed JSON. |
---|