A connection to the broker.
Parameters: |
|
---|
Usage
Creating a connection:
>>> conn = BrokerConnection("rabbit.example.com")
The connection is established lazily when needed. If you need the connection to be established, then do so expliclty using connect():
>>> conn.connect()
Remember to always close the connection:
>>> conn.release()
Create new SimpleQueue using a channel from this connection.
Same as SimpleQueue(), but configured with buffering semantics. The resulting queue and exchange will not be durable, also auto delete is enabled. Messages will be transient (not persistent), and acknowledgements are disabled (no_ack).
Create new SimpleQueue, using a channel from this connection.
If name is a string, a queue and exchange will be automatically created using that name as the name of the queue and exchange, also it will be used as the default routing key.
Parameters: |
|
---|
Acquire connection.
Only here for API compatibility with BrokerConnectionPool.
Request a new channel.
List of exceptions that may be raised by the channel.
Create a copy of the connection with the same connection settings.
Close the connection (if open).
Establish connection to server immediately.
List of exceptions that may be raised by the connection.
Wait for a single event from the server.
Parameters: |
|
---|
Usually used from an event loop.
Ensure operation completes, regardless of any channel/connection errors occuring.
Will retry by establishing the connection, and reapplying the function.
Parameters: |
|
---|
Example
This is an example ensuring a publish operation:
>>> def errback(exc, interval):
... print("Couldn't publish message: %r. Retry in %ds" % (
... exc, interval))
>>> publish = conn.ensure(producer.publish,
... errback=errback, max_retries=3)
>>> publish(message, routing_key)
Ensure we have a connection to the server.
If not retry establishing the connection with the settings specified.
Parameters: |
|
---|
Get the currently used transport class.
The host as a hostname/port pair separated by colon.
Get connection info.
Close the connection, or if the connection is managed by a pool the connection will be released to the pool so it can be reused.
NOTE: You must never perform operations on a connection that has been released.
Pool of connections.
Parameters: |
|
---|
Acquire connection.
Raises kombu.exceptions.PoolExhausted: | |
---|---|
If there are no available connections to be acquired. |
Number of acquired connections.
Close all connections.
Add n more connections to the pool.
Parameters: |
|
---|---|
Raises kombu.exceptions.PoolLimitExceeded: | |
If there are already more than max number of connections in the pool. |
Release connection so it can be used by others.
NOTE: You must never perform operations on a connection that has been released.
Clone and replace connection with a new one.
This is useful if the connection is broken.
Current total number of connections