carrot.backends.pyamqplib

amqplib backend for carrot.

class carrot.backends.pyamqplib.Backend(connection, **kwargs)

amqplib backend

Parameters:
connection

A carrot.connection.BrokerConnection instance. An established connection to the broker.

class 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:
body

The message body.

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. This is a private attribute and should not be accessed by production code.

Backend.ack(delivery_tag)

Acknowledge a message by delivery tag.

Backend.cancel(consumer_tag)

Cancel a channel by consumer tag.

Backend.channel

If no channel exists, a new one is requested.

Backend.close()

Close the channel if open.

Backend.close_connection(connection)

Close the AMQP broker connection.

Backend.consume(limit=None)

Returns an iterator that waits for one message at a time.

Backend.declare_consumer(queue, no_ack, callback, consumer_tag, nowait=False)

Declare a consumer.

Backend.establish_connection()

Establish connection to the AMQP broker.

Backend.exchange_declare(exchange, type, durable, auto_delete)

Declare an named exchange.

Backend.flow(active)

Enable/disable flow from peer.

Backend.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.
Backend.message_to_python(raw_message)

Convert encoded message body back to a Python value.

Backend.prepare_message(message_data, delivery_mode, priority=None, content_type=None, content_encoding=None)

Encapsulate data into a AMQP message.

Backend.publish(message, exchange, routing_key, mandatory=None, immediate=None, headers=None)

Publish a message to a named exchange.

Backend.qos(prefetch_size, prefetch_count, apply_global=False)

Request specific Quality of Service.

Backend.queue_bind(queue, exchange, routing_key, arguments=None)

Bind queue to an exchange using a routing key.

Backend.queue_declare(queue, durable, exclusive, auto_delete, warn_if_exists=False, arguments=None)

Declare a named queue.

Backend.queue_delete(queue, if_unused=False, if_empty=False)

Delete queue by name.

Backend.queue_exists(queue)

Check if a queue has been declared.

Rtype bool:
Backend.queue_purge(queue, **kwargs)

Discard all messages in the queue. This will delete the messages and results in an empty queue.

Backend.reject(delivery_tag)

Reject a message by deliver tag.

Backend.requeue(delivery_tag)

Reject and requeue a message by delivery tag.

class carrot.backends.pyamqplib.Connection(host='localhost', userid='guest', password='guest', login_method='AMQPLAIN', login_response=None, virtual_host='/', locale='en_US', client_properties=None, ssl=False, insist=False, connect_timeout=None, **kwargs)
drain_events(allowed_methods=None, timeout=None)

Wait for an event on any channel.

read_timeout(timeout=None)
wait_multi(channels, allowed_methods=None, timeout=None)

Wait for an event on a channel.

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:
body

The message body.

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. This is a private attribute and should not be accessed by production code.

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.

Previous topic

carrot.backends.base

Next topic

carrot.backends.pikachu

This Page