carrot.connection

Getting a connection to the AMQP server.

carrot.connection.AMQPConnection

alias of BrokerConnection

class carrot.connection.BrokerConnection(hostname=None, userid=None, password=None, virtual_host=None, port=None, pool=None, **kwargs)

A network/socket connection to an AMQP message broker.

Parameters:
hostname

The hostname to the AMQP server

userid

A valid username used to authenticate to the server.

password

The password used to authenticate to the server.

virtual_host

The name of the virtual host to work with. This virtual host must exist on the server, and the user must have access to it. Consult your brokers manual for help with creating, and mapping users to virtual hosts. Default is "/".

port

The port of the AMQP server. Default is 5672 (amqp).

insist

Insist on connecting to a server. In a configuration with multiple load-sharing servers, the insist option tells the server that the client is insisting on a connection to the specified server. Default is False.

connect_timeout

The timeout in seconds before we give up connecting to the server. The default is no timeout.

ssl

Use SSL to connect to the server. The default is False.

backend_cls

The messaging backend class used. Defaults to the pyamqplib backend.

ConnectionException

alias of AMQPConnectionException

close()

Close the currently open connection.

connect()

Establish a connection to the AMQP server.

connection
create_backend()

Create a new instance of the current backend in backend_cls.

drain_events(**kwargs)
get_backend_cls()

Get the currently used backend class.

get_channel()

Request a new AMQP channel.

host

The host as a hostname/port pair separated by colon.

release()
exception carrot.connection.ConnectionLimitExceeded

The maximum number of pool connections has been exceeded.

class carrot.connection.ConnectionPool(source_connection, min=2, max=None, preload=True)
acquire(block=False, timeout=None, connect_timeout=None)
release(connection)
carrot.connection.DjangoAMQPConnection

alias of DjangoBrokerConnection

class carrot.connection.DjangoBrokerConnection(*args, **kwargs)

A version of BrokerConnection that takes configuration from the Django settings.py module.

Parameters:
  • hostname – The hostname of the AMQP server to connect to, if not provided this is taken from settings.BROKER_HOST.
  • userid – The username of the user to authenticate to the server as. If not provided this is taken from settings.BROKER_USER.
  • password – The users password. If not provided this is taken from settings.BROKER_PASSWORD.
  • virtual_host – The name of the virtual host to work with. This virtual host must exist on the server, and the user must have access to it. Consult your brokers manual for help with creating, and mapping users to virtual hosts. If not provided this is taken from settings.BROKER_VHOST.
  • port – The port the AMQP server is running on. If not provided this is taken from settings.BROKER_PORT, or if that is not set, the default is 5672 (amqp).
carrot.connection.get_django_conninfo(settings=None)

Previous topic

API Reference

Next topic

carrot.messaging

This Page