carrot.backends.pyamqplib¶
amqplib backend for carrot.
- class carrot.backends.pyamqplib.Backend(connection, **kwargs)¶
amqplib backend
Parameters: - connection – see connection.
- encoder – see encoder.
- decoder – see decoder.
- connection¶
A carrot.connection.AMQPConnection instance. An established connection to the AMQP server.
- encoder¶
A function that serializes to the format used. Defaults to carrot.serialization.serialize().
- decoder¶
A function that decodes objects serialized in the serialization format used. Defaults to carrot.serialization.deserialize().
- ack(delivery_tag)¶
- Acknowledge a message by delivery tag.
- cancel(consumer_tag)¶
- Cancel a channel by consumer tag.
- close()¶
- Close the channel if open.
- consume(queue, no_ack, callback, consumer_tag, limit=None)¶
- Returns an iterator that waits for one message at a time, calling the callback when messages arrive.
- exchange_declare(exchange, type, durable, auto_delete)¶
- Declare an named exchange.
- get(queue, no_ack=False)¶
Receive a message from a declared queue by name.
Returns: A Message object if a message was received, None otherwise. If None was returned, it probably means there was no messages waiting on the queue.
- prepare_message(message_data, delivery_mode, priority=None)¶
- Encapsulate data into a AMQP message.
- publish(message, exchange, routing_key, mandatory=None, immediate=None)¶
- Publish a message to a named exchange.
- queue_bind(queue, exchange, routing_key)¶
- Bind queue to an exchange using a routing key.
- queue_declare(queue, durable, exclusive, auto_delete, warn_if_exists=False)¶
- Declare a named queue.
- reject(delivery_tag)¶
- Reject a message by deliver tag.
- requeue(delivery_tag)¶
- Reject and requeue a message by delivery tag.
- class carrot.backends.pyamqplib.Message(backend, amqp_message, **kwargs)¶
A message received by the broker.
Usually you don’t insantiate message objects yourself, but receive them using a carrot.messaging.Consumer.
Parameters: - backend – see backend.
- amqp_message – see amqp_message.
- channel – see channel.
- decoder – see decoder.
- body¶
- The message body. This data is serialized, so you probably want to deserialize it using carrot.backends.base.BaseMessage.decode().
- delivery_tag¶
- The message delivery tag, uniquely identifying this message.
- backend¶
- The message backend used. A subclass of carrot.backends.base.BaseBackend.
- amqp_message¶
- A amqplib.client_0_8.basic_message.Message instance.
- channel¶
- The AMQP channel. A amqplib.client_0_8.channel.Channel instance.
- decoder¶
- A function able to deserialize the serialized message data.
- exception carrot.backends.pyamqplib.QueueAlreadyExistsWarning¶
- A queue with that name already exists, so a recently changed routing_key or other settings might be ignored unless you rename the queue or restart the broker.