master PDF - Read the Docs

master PDF - Read the Docs
Kombu Documentation
Release 4.0.0a1
Ask Solem
March 10, 2016
Contents
1
kombu - Messaging library for Python
1.1 Features . . . . . . . . . . . . . .
1.2 Transport Comparison . . . . . .
1.3 Installation . . . . . . . . . . . .
1.4 Terminology . . . . . . . . . . .
1.5 Getting Help . . . . . . . . . . .
1.6 Bug tracker . . . . . . . . . . . .
1.7 Contributing . . . . . . . . . . .
1.8 License . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
4
5
6
7
7
7
7
User Guide
2.1 Introduction . . . . . . . . . .
2.2 Connections and transports . . .
2.3 Producers . . . . . . . . . . . .
2.4 Consumers . . . . . . . . . . .
2.5 Examples . . . . . . . . . . . .
2.6 Simple Interface . . . . . . . .
2.7 Connection and Producer Pools
2.8 Serialization . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
9
9
10
13
13
16
18
20
22
3
Frequently Asked Questions
3.1 Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
25
4
API Reference
4.1 Connection . . . . . . . . . . . . . . . . . .
4.2 Exchange . . . . . . . . . . . . . . . . . . .
4.3 Queue . . . . . . . . . . . . . . . . . . . . .
4.4 Message Producer . . . . . . . . . . . . . .
4.5 Message Consumer . . . . . . . . . . . . . .
4.6 Common Utilities - kombu.common . . . . .
4.7 Mixin Classes - kombu.mixins . . . . . . . .
4.8 Clocks and Synchronization - kombu.clocks
4.9 kombu.exceptions . . . . . . . . . . . . . .
4.10 Logging - kombu.log . . . . . . . . . . . . .
4.11 Message Objects - kombu.message . . . . .
4.12 General Pools - kombu.pools . . . . . . . . .
4.13 Async Utilities - kombu.syn . . . . . . . . .
4.14 Event Loop - kombu.async . . . . . . . . . .
27
27
27
28
28
28
28
28
28
28
29
29
29
29
31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. . . . . . . . . . .
Debugging Utils - kombu.async.debug . . . . . . . . . .
kombu.transport.zmq . . . . . . . . . . . . . . . . . . . .
kombu.transport.zookeeper . . . . . . . . . . . . . . . .
kombu.transport.django . . . . . . . . . . . . . . . . . .
Django Models - kombu.transport.django.models . . . . .
Django Managers - kombu.transport.django.managers . .
Django Management - clean_kombu_messages . . . . . .
kombu.transport.sqlalchemy . . . . . . . . . . . . . . . .
kombu.transport.SLMQ . . . . . . . . . . . . . . . . . .
Utilities - kombu.utils . . . . . . . . . . . . . . . . . . .
Evented I/O - kombu.utils.eventio . . . . . . . . . . . . .
Rate limiting - kombu.utils.limits . . . . . . . . . . . . .
Debugging - kombu.utils.debug . . . . . . . . . . . . . .
String Encoding - kombu.utils.encoding . . . . . . . . . .
kombu.utils.functional . . . . . . . . . . . . . . . . . . .
kombu.utils.url . . . . . . . . . . . . . . . . . . . . . . .
Text utilitites - kombu.utils.text . . . . . . . . . . . . . .
Generic RabbitMQ manager - kombu.utils.amq_manager .
Python 2 to Python 3 utilities - kombu.five . . . . . . . .
Change history
5.1 4.0 . . .
5.2 3.0.28 . .
5.3 3.0.27 . .
5.4 3.0.26 . .
5.5 3.0.25 . .
5.6 3.0.24 . .
5.7 3.0.23 . .
5.8 3.0.22 . .
5.9 3.0.21 . .
5.10 3.0.20 . .
5.11 3.0.19 . .
5.12 3.0.18 . .
5.13 3.0.17 . .
5.14 3.0.16 . .
5.15 3.0.15 . .
5.16 3.0.14 . .
5.17 3.0.13 . .
5.18 3.0.12 . .
5.19 3.0.11 . .
5.20 3.0.10 . .
5.21 3.0.9 . .
5.22 3.0.8 . .
5.23 3.0.7 . .
5.24 3.0.6 . .
5.25 3.0.5 . .
5.26 3.0.4 . .
5.27 3.0.3 . .
5.28 3.0.2 . .
5.29 3.0.1 . .
5.30 3.0.0 . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
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
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
71
71
72
72
72
72
73
74
75
75
76
76
76
77
77
77
78
79
79
79
80
80
80
80
80
Indices and tables
81
Python Module Index
83
iv
Kombu Documentation, Release 4.0.0a1
Contents:
Contents
1
Kombu Documentation, Release 4.0.0a1
2
Contents
CHAPTER 1
kombu - Messaging library for Python
Version 4.0.0a1
Kombu is a messaging library for Python.
The aim of Kombu is to make messaging in Python as easy as possible by providing an idiomatic high-level interface
for the AMQ protocol, and also provide proven and tested solutions to common messaging problems.
AMQP is the Advanced Message Queuing Protocol, an open standard protocol for message orientation, queuing,
routing, reliability and security, for which the RabbitMQ messaging server is the most popular implementation.
1.1 Features
• Allows application authors to support several message server solutions by using pluggable transports.
– AMQP transport using the py-amqp, librabbitmq, or qpid-python libraries.
– High performance AMQP transport written in C - when using librabbitmq
This is automatically enabled if librabbitmq is installed:
$ pip install librabbitmq
– Virtual transports makes it really easy to add support for non-AMQP transports. There is already built-in
support for Redis, Beanstalk, Amazon SQS, CouchDB, MongoDB, ZeroMQ, ZooKeeper, SoftLayer MQ
and Pyro.
– You can also use the SQLAlchemy and Django ORM transports to use a database as the broker.
– In-memory transport for unit testing.
• Supports automatic encoding, serialization and compression of message payloads.
• Consistent exception handling across transports.
• The ability to ensure that an operation is performed by gracefully handling connection and channel errors.
• Several annoyances with amqplib has been fixed, like supporting timeouts and the ability to wait for events on
more than one channel.
• Projects already using carrot can easily be ported by using a compatibility layer.
For an introduction to AMQP you should read the article Rabbits and warrens, and the Wikipedia article about AMQP.
3
Kombu Documentation, Release 4.0.0a1
1.2 Transport Comparison
Client
amqp
qpid
redis
mongodb
beanstalk
SQS
couchdb
zookeeper
in-memory
django
sqlalchemy
SLMQ
Type
Native
Native
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Direct
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Topic
Yes
Yes
Yes
Yes
Yes 1
Yes 1
Yes 1
Yes 1
Yes 1
Yes 1
Yes 1
Yes 1
Fanout
Yes
Yes
Yes (PUB/SUB)
Yes
No
Yes 2
No
No
No
No
No
No
Priority
Yes 3
No
Yes
Yes
Yes
No
No
Yes
No
No
No
No
TTL
Yes 4
No
No
Yes
No
No
No
No
No
No
No
No
1.2.1 Documentation
Kombu is using Sphinx, and the latest documentation can be found here:
http://kombu.readthedocs.org/
1.2.2 Quick overview
from kombu import Connection, Exchange, Queue
media_exchange = Exchange('media', 'direct', durable=True)
video_queue = Queue('video', exchange=media_exchange, routing_key='video')
def process_media(body, message):
print body
message.ack()
# connections
with Connection('amqp://guest:guest@localhost//') as conn:
# produce
producer = conn.Producer(serializer='json')
producer.publish({'name': '/tmp/lolcat1.avi', 'size': 1301013},
exchange=media_exchange, routing_key='video',
declare=[video_queue])
#
#
#
#
#
#
the declare above, makes sure the video queue is declared
so that the messages can be delivered.
It's a best practice in Kombu to have both publishers and
consumers declare the queue. You can also declare the
queue manually using:
video_queue(conn).declare()
3 AMQP
Message priority support depends on broker implementation.
Message/Queue TTL support depends on broker implementation.
1 Declarations only kept in memory, so exchanges/queues must be declared by all clients that needs them.
2 Fanout supported via storing routing tables in SimpleDB. Disabled by default, but can be enabled by using the supports_fanout transport
option.
4 AMQP
4
Chapter 1. kombu - Messaging library for Python
Kombu Documentation, Release 4.0.0a1
# consume
with conn.Consumer(video_queue, callbacks=[process_media]) as consumer:
# Process messages and handle events on all channels
while True:
conn.drain_events()
# Consume from several queues on the same channel:
video_queue = Queue('video', exchange=media_exchange, key='video')
image_queue = Queue('image', exchange=media_exchange, key='image')
with connection.Consumer([video_queue, image_queue],
callbacks=[process_media]) as consumer:
while True:
connection.drain_events()
Or handle channels manually:
with connection.channel() as channel:
producer = Producer(channel, ...)
consumer = Producer(channel)
All objects can be used outside of with statements too, just remember to close the objects after use:
from kombu import Connection, Consumer, Producer
connection = Connection()
# ...
connection.release()
consumer = Consumer(channel_or_connection, ...)
consumer.register_callback(my_callback)
consumer.consume()
# ....
consumer.cancel()
Exchange and Queue are simply declarations that can be pickled and used in configuration files etc.
They also support operations, but to do so they need to be bound to a channel.
Binding exchanges and queues to a connection will make it use that connections default channel.
>>> exchange = Exchange('tasks', 'direct')
>>> connection = Connection()
>>> bound_exchange = exchange(connection)
>>> bound_exchange.delete()
# the original exchange is not affected, and stays unbound.
>>> exchange.delete()
raise NotBoundError: Can't call delete on Exchange not bound to
a channel.
1.3 Installation
You can install Kombu either via the Python Package Index (PyPI) or from source.
To install using pip,:
1.3. Installation
5
Kombu Documentation, Release 4.0.0a1
$ pip install kombu
To install using easy_install,:
$ easy_install kombu
If you have downloaded a source tarball you can install it by doing the following,:
$ python setup.py build
# python setup.py install # as root
1.4 Terminology
There are some concepts you should be familiar with before starting:
• Producers
Producers sends messages to an exchange.
• Exchanges
Messages are sent to exchanges. Exchanges are named and can be configured to use one of several
routing algorithms. The exchange routes the messages to consumers by matching the routing key in
the message with the routing key the consumer provides when binding to the exchange.
• Consumers
Consumers declares a queue, binds it to a exchange and receives messages from it.
• Queues
Queues receive messages sent to exchanges. The queues are declared by consumers.
• Routing keys
Every message has a routing key. The interpretation of the routing key depends on the exchange
type. There are four default exchange types defined by the AMQP standard, and vendors can define
custom types (so see your vendors manual for details).
These are the default exchange types defined by AMQP/0.8:
– Direct exchange
Matches if the routing key property of the message and the routing_key attribute of the
consumer are identical.
– Fan-out exchange
Always matches, even if the binding does not have a routing key.
– Topic exchange
Matches the routing key property of the message by a primitive pattern matching
scheme. The message routing key then consists of words separated by dots (”.”,
like domain names), and two special characters are available; star (“*”) and hash
(“#”). The star matches any word, and the hash matches zero or more words. For
example “*.stock.#” matches the routing keys “usd.stock” and “eur.stock.db” but not
“stock.nasdaq”.
6
Chapter 1. kombu - Messaging library for Python
Kombu Documentation, Release 4.0.0a1
1.5 Getting Help
1.5.1 Mailing list
Join the carrot-users mailing list.
1.6 Bug tracker
If you have any suggestions, bug reports or annoyances please report them to our issue tracker at
http://github.com/celery/kombu/issues/
1.7 Contributing
Development of Kombu happens at Github: http://github.com/celery/kombu
You are highly encouraged to participate in the development. If you don’t like Github (for some reason) you’re
welcome to send regular patches.
1.8 License
This software is licensed under the New BSD License. See the LICENSE file in the top distribution directory for the
full license text.
1.5. Getting Help
7
Kombu Documentation, Release 4.0.0a1
8
Chapter 1. kombu - Messaging library for Python
CHAPTER 2
User Guide
Release 4.0
Date March 10, 2016
2.1 Introduction
2.1.1 What is messaging?
In times long ago people didn’t have email. They had the postal service, which with great courage would deliver mail
from hand to hand all over the globe. Soldiers deployed at wars far away could only communicate with their families
through the postal service, and posting a letter would mean that the recipient wouldn’t actually receive the letter until
weeks or months, sometimes years later.
It’s hard to imagine this today when people are expected to be available for phone calls every minute of the day.
So humans need to communicate with each other, this shouldn’t be news to anyone, but why would applications?
One example is banks. When you transfer money from one bank to another, your bank sends a message to a central
clearinghouse. The clearinghouse then records and coordinates the transaction. Banks need to send and receive
millions and millions of messages every day, and losing a single message would mean either losing your money (bad)
or the banks money (very bad)
Another example is the stock exchanges, which also have a need for very high message throughputs and have strict
reliability requirements.
Email is a great way for people to communicate. It is much faster than using the postal service, but still using email
as a means for programs to communicate would be like the soldier above, waiting for signs of life from his girlfriend
back home.
2.1.2 Messaging Scenarios
• Request/Reply
The request/reply pattern works like the postal service example. A message is addressed to a single recipient,
with a return address printed on the back. The recipient may or may not reply to the message by sending it back
to the original sender.
Request-Reply is achieved using direct exchanges.
9
Kombu Documentation, Release 4.0.0a1
• Broadcast
In a broadcast scenario a message is sent to all parties. This could be none, one or many recipients.
Broadcast is achieved using fanout exchanges.
• Publish/Subscribe
In a publish/subscribe scenario producers publish messages to topics, and consumers subscribe to the topics they
are interested in.
If no consumers subscribe to the topic, then the message will not be delivered to anyone. If several consumers
subscribe to the topic, then the message will be delivered to all of them.
Pub-sub is achieved using topic exchanges.
2.1.3 Reliability
For some applications reliability is very important. Losing a message is a critical situation that must never happen.
For other applications losing a message is fine, it can maybe recover in other ways, or the message is resent anyway
as periodic updates.
AMQP defines two built-in delivery modes:
• persistent
Messages are written to disk and survives a broker restart.
• transient
Messages may or may not be written to disk, as the broker sees fit to optimize memory contents. The
messages will not survive a broker restart.
Transient messaging is by far the fastest way to send and receive messages, so having persistent messages comes with
a price, but for some applications this is a necessary cost.
2.2 Connections and transports
2.2.1 Basics
To send and receive messages you need a transport and a connection. There are several transports to choose from
(amqp, librabbitmq, redis, qpid, in-memory, etc.), and you can even create your own. The default transport is amqp.
Create a connection using the default transport:
>>> from kombu import Connection
>>> connection = Connection('amqp://guest:guest@localhost:5672//')
The connection will not be established yet, as the connection is established when needed. If you want to explicitly
establish the connection you have to call the connect() method:
>>> connection.connect()
You can also check whether the connection is connected:
>>> connection.connected
True
Connections must always be closed after use:
10
Chapter 2. User Guide
Kombu Documentation, Release 4.0.0a1
>>> connection.close()
But best practice is to release the connection instead, this will release the resource if the connection is associated with
a connection pool, or close the connection if not, and makes it easier to do the transition to connection pools later:
>>> connection.release()
See also:
Connection and Producer Pools
Of course, the connection can be used as a context, and you are encouraged to do so as it makes it harder to forget
releasing open resources:
with Connection() as connection:
# work with connection
2.2.2 URLs
Connection parameters can be provided as an URL in the format:
transport://userid:password@hostname:port/virtual_host
All of these are valid URLs:
# Specifies using the amqp transport only, default values
# are taken from the keyword arguments.
amqp://
# Using Redis
redis://localhost:6379/
# Using Redis over a Unix socket
redis+socket:///tmp/redis.sock
# Using Qpid
qpid://localhost/
# Using virtual host '/foo'
amqp://localhost//foo
# Using virtual host 'foo'
amqp://localhost/foo
The query part of the URL can also be used to set options, e.g.:
amqp://localhost/myvhost?ssl=1
See Keyword arguments for a list of supported options.
A connection without options will use the default connection settings, which is using the localhost host, default port,
user name guest, password guest and virtual host “/”. A connection without arguments is the same as:
>>> Connection('amqp://guest:guest@localhost:5672//')
The default port is transport specific, for AMQP this is 5672.
Other fields may also have different meaning depending on the transport used. For example, the Redis transport uses
the virtual_host argument as the redis database number.
2.2. Connections and transports
11
Kombu Documentation, Release 4.0.0a1
2.2.3 Keyword arguments
The Connection class supports additional keyword arguments, these are:
hostname Default host name if not provided in the URL.
userid Default user name if not provided in the URL.
password Default password if not provided in the URL.
virtual_host Default virtual host if not provided in the URL.
port Default port if not provided in the URL.
transport Default transport if not provided in the URL. Can be a string specifying the path to the
class. (e.g. kombu.transport.pyamqp:Transport), or one of the aliases: pyamqp,
librabbitmq, redis, qpid, memory, and so on.
ssl Use SSL to connect to the server. Default is False. Only supported by the amqp and qpid transports.
insist Insist on connecting to a server. No longer supported, relic from AMQP 0.8
connect_timeout Timeout in seconds for connecting to the server. May not be supported by the specified
transport.
transport_options A dict of additional connection arguments to pass to alternate kombu channel implementations. Consult the transport documentation for available options.
2.2.4 AMQP Transports
There are 4 transports available for AMQP use.
1. pyamqp uses the pure Python library amqp, automatically installed with Kombu.
2. librabbitmq uses the high performance transport written in C. This requires the librabbitmq Python
package to be installed, which automatically compiles the C library.
3. amqp tries to use librabbitmq but falls back to pyamqp.
4. qpid uses the pure Python library qpid.messaging, automatically installed with Kombu. The Qpid library
uses AMQP, but uses custom extensions specifically supported by the Apache Qpid Broker.
For the highest performance, you should install the librabbitmq package. To ensure librabbitmq is used, you can
explicitly specify it in the transport URL, or use amqp to have the fallback.
12
Chapter 2. User Guide
Kombu Documentation, Release 4.0.0a1
2.2.5 Transport Comparison
Client
amqp
qpid
redis
mongodb
beanstalk
SQS
couchdb
zookeeper
in-memory
django
sqlalchemy
SLMQ
Type
Native
Native
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Virtual
Direct
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Topic
Yes
Yes
Yes
Yes
Yes 1
Yes 1
Yes 1
Yes 1
Yes 1
Yes 1
Yes 1
Yes 1
Fanout
Yes
Yes
Yes (PUB/SUB)
Yes
No
Yes 2
No
No
No
No
No
No
Priority
Yes 3
No
Yes
Yes
Yes
No
No
Yes
No
No
No
No
2.3 Producers
2.3.1 Basics
2.3.2 Serialization
See Serialization.
2.3.3 Reference
2.4 Consumers
2.4.1 Basics
The Consumer takes a connection (or channel) and a list of queues to consume from. Several consumers can be
mixed to consume from different channels, as they all bind to the same connection, and drain_events will drain
events from all channels on that connection.
Note: Kombu since 3.0 will only accept json/binary or text messages by default, to allow deserialization of other
formats you have to specify them in the accept argument:
Consumer(conn, accept=['json', 'pickle', 'msgpack', 'yaml'])
Draining events from a single consumer:
with Consumer(connection, queues, accept=['json']):
connection.drain_events(timeout=1)
3 AMQP
Message priority support depends on broker implementation.
only kept in memory, so exchanges/queues must be declared by all clients that needs them.
2 Fanout supported via storing routing tables in SimpleDB. Disabled by default, but can be enabled by using the supports_fanout transport
option.
1 Declarations
2.3. Producers
13
Kombu Documentation, Release 4.0.0a1
Draining events from several consumers:
from kombu.utils import nested
with connection.channel(), connection.channel() as (channel1, channel2):
with nested(Consumer(channel1, queues1, accept=['json']),
Consumer(channel2, queues2, accept=['json'])):
connection.drain_events(timeout=1)
Or using ConsumerMixin:
from kombu.mixins import ConsumerMixin
class C(ConsumerMixin):
def __init__(self, connection):
self.connection = connection
def get_consumers(self, Consumer, channel):
return [
Consumer(queues, callbacks=[self.on_message], accept=['json']),
]
def on_message(self, body, message):
print("RECEIVED MESSAGE: {0!r}".format(body))
message.ack()
C(connection).run()
and with multiple channels again:
from kombu import Consumer
from kombu.mixins import ConsumerMixin
class C(ConsumerMixin):
channel2 = None
def __init__(self, connection):
self.connection = connection
def get_consumers(self, _, default_channel):
self.channel2 = default_channel.connection.channel()
return [Consumer(default_channel, queues1,
callbacks=[self.on_message],
accept=['json']),
Consumer(self.channel2, queues2,
callbacks=[self.on_special_message],
accept=['json'])]
def on_consumer_end(self, connection, default_channel):
if self.channel2:
self.channel2.close()
C(connection).run()
There’s also a ConsumerProducerMixin for consumers that need to also publish messages on a separate connection (e.g. sending rpc replies, streaming results):
14
Chapter 2. User Guide
Kombu Documentation, Release 4.0.0a1
from kombu import Producer, Queue
from kombu.mixins import ConsumerProducerMixin
rpc_queue = Queue('rpc_queue')
class Worker(ConsumerProducerMixin):
def __init__(self, connection):
self.connection = connection
def get_consumers(self, Consumer, channel):
return [Consumer(
queues=[rpc_queue],
on_message=self.on_request,
accept={'application/json'},
prefetch_count=1,
)]
def on_request(self, message):
n = message.payload['n']
print(' [.] fib({0})'.format(n))
result = fib(n)
self.producer.publish(
{'result': result},
exchange='', routing_key=message.properties['reply_to'],
correlation_id=message.properties['correlation_id'],
serializer='json',
retry=True,
)
message.ack()
See also:
examples/rpc-tut6/ in the Github repository.
2.4.2 Advanced Topics
RabbitMQ
Consumer Priorities
RabbitMQ defines a consumer priority extension to the amqp protocol, that can be enabled by setting the
x-priority argument to basic.consume.
In kombu you can specify this argument on the Queue, like this:
queue = Queue('name', Exchange('exchange_name', type='direct'),
consumer_arguments={'x-priority': 10})
Read more about consumer priorities here: https://www.rabbitmq.com/consumer-priority.html
2.4. Consumers
15
Kombu Documentation, Release 4.0.0a1
2.4.3 Reference
2.5 Examples
2.5.1 Hello World Example
Below example uses Simple Interface to send helloworld message through message broker (rabbitmq) and print received message
hello_publisher.py:
from kombu import Connection
import datetime
with Connection('amqp://guest:guest@localhost:5672//') as conn:
simple_queue = conn.SimpleQueue('simple_queue')
message = 'helloword, sent at %s' % datetime.datetime.today()
simple_queue.put(message)
print('Sent: %s' % message)
simple_queue.close()
hello_consumer.py:
from kombu import Connection
with Connection('amqp://guest:guest@localhost:5672//') as conn:
simple_queue = conn.SimpleQueue('simple_queue')
message = simple_queue.get(block=True, timeout=1)
print("Received: %s" % message.payload)
message.ack()
simple_queue.close()
2.5.2 Task Queue Example
Very simple task queue using pickle, with primitive support for priorities using different queues.
queues.py:
from kombu import Exchange, Queue
task_exchange = Exchange('tasks', type='direct')
task_queues = [Queue('hipri', task_exchange, routing_key='hipri'),
Queue('midpri', task_exchange, routing_key='midpri'),
Queue('lopri', task_exchange, routing_key='lopri')]
worker.py:
from kombu.mixins import ConsumerMixin
from kombu.log import get_logger
from kombu.utils import reprcall
from .queues import task_queues
logger = get_logger(__name__)
16
Chapter 2. User Guide
Kombu Documentation, Release 4.0.0a1
class Worker(ConsumerMixin):
def __init__(self, connection):
self.connection = connection
def get_consumers(self, Consumer, channel):
return [Consumer(queues=task_queues,
accept=['pickle', 'json'],
callbacks=[self.process_task])]
def process_task(self, body, message):
fun = body['fun']
args = body['args']
kwargs = body['kwargs']
logger.info('Got task: %s', reprcall(fun.__name__, args, kwargs))
try:
fun(*args, **kwargs)
except Exception as exc:
logger.error('task raised exception: %r', exc)
message.ack()
if __name__ == '__main__':
from kombu import Connection
from kombu.utils.debug import setup_logging
# setup root logger
setup_logging(loglevel='INFO', loggers=[''])
with Connection('amqp://guest:guest@localhost:5672//') as conn:
try:
worker = Worker(conn)
worker.run()
except KeyboardInterrupt:
print('bye bye')
tasks.py:
def hello_task(who="world"):
print("Hello {0}".format(who))
client.py:
from kombu.pools import producers
from .queues import task_exchange
priority_to_routing_key = {'high': 'hipri',
'mid': 'midpri',
'low': 'lopri'}
def send_as_task(connection, fun, args=(), kwargs={}, priority='mid'):
payload = {'fun': fun, 'args': args, 'kwargs': kwargs}
routing_key = priority_to_routing_key[priority]
with producers[connection].acquire(block=True) as producer:
producer.publish(payload,
serializer='pickle',
2.5. Examples
17
Kombu Documentation, Release 4.0.0a1
compression='bzip2',
exchange=task_exchange,
declare=[task_exchange],
routing_key=routing_key)
if __name__ == '__main__':
from kombu import Connection
from .tasks import hello_task
connection = Connection('amqp://guest:guest@localhost:5672//')
send_as_task(connection, fun=hello_task, args=('Kombu',), kwargs={},
priority='high')
2.6 Simple Interface
• Sending and receiving messages
kombu.simple is a simple interface to AMQP queueing. It is only slightly different from the Queue class in the
Python Standard Library, which makes it excellent for users with basic messaging needs.
Instead of defining exchanges and queues, the simple classes only requires two arguments, a connection channel and
a name. The name is used as the queue, exchange and routing key. If the need arises, you can specify a Queue as the
name argument instead.
In addition, the Connection comes with shortcuts to create simple queues using the current connection:
>>> queue = connection.SimpleQueue('myqueue')
>>> # ... do something with queue
>>> queue.close()
This is equivalent to:
>>> from kombu import SimpleQueue, SimpleBuffer
>>>
>>>
>>>
>>>
>>>
channel = connection.channel()
queue = SimpleBuffer(channel)
# ... do something with queue
channel.close()
queue.close()
2.6.1 Sending and receiving messages
The simple interface defines two classes; SimpleQueue, and SimpleBuffer. The former is used for persistent
messages, and the latter is used for transient, buffer-like queues. They both have the same interface, so you can use
them interchangeably.
Here is an example using the SimpleQueue class to produce and consume logging messages:
import socket
import datetime
from time import time
from kombu import Connection
18
Chapter 2. User Guide
Kombu Documentation, Release 4.0.0a1
class Logger(object):
def __init__(self, connection, queue_name='log_queue',
serializer='json', compression=None):
self.queue = connection.SimpleQueue(queue_name)
self.serializer = serializer
self.compression = compression
def log(self, message, level='INFO', context={}):
self.queue.put({'message': message,
'level': level,
'context': context,
'hostname': socket.gethostname(),
'timestamp': time()},
serializer=self.serializer,
compression=self.compression)
def process(self, callback, n=1, timeout=1):
for i in xrange(n):
log_message = self.queue.get(block=True, timeout=1)
entry = log_message.payload # deserialized data.
callback(entry)
log_message.ack() # remove message from queue
def close(self):
self.queue.close()
if __name__ == '__main__':
from contextlib import closing
with Connection('amqp://guest:guest@localhost:5672//') as conn:
with closing(Logger(conn)) as logger:
# Send message
logger.log('Error happened while encoding video',
level='ERROR',
context={'filename': 'cutekitten.mpg'})
# Consume and process message
# This is the callback called when a log message is
# received.
def dump_entry(entry):
date = datetime.datetime.fromtimestamp(entry['timestamp'])
print('[%s %s %s] %s %r' % (date,
entry['hostname'],
entry['level'],
entry['message'],
entry['context']))
# Process a single message using the callback above.
logger.process(dump_entry, n=1)
2.6. Simple Interface
19
Kombu Documentation, Release 4.0.0a1
2.7 Connection and Producer Pools
2.7.1 Default Pools
Kombu ships with two global pools: one connection pool, and one producer pool.
These are convenient and the fact that they are global may not be an issue as connections should often be limited at the
process level, rather than per thread/application and so on, but if you need custom pools per thread see Custom Pool
Groups.
The connection pool group
The connection pools are available as kombu.pools.connections. This is a pool group, which means you give
it a connection instance, and you get a pool instance back. We have one pool per connection instance to support
multiple connections in the same app. All connection instances with the same connection parameters will get the same
pool:
>>> from kombu import Connection
>>> from kombu.pools import connections
>>> connections[Connection('redis://localhost:6379')]
<kombu.connection.ConnectionPool object at 0x101805650>
>>> connections[Connection('redis://localhost:6379')]
<kombu.connection.ConnectionPool object at 0x101805650>
Let’s acquire and release a connection:
from kombu import Connection
from kombu.pools import connections
connection = Connection('redis://localhost:6379')
with connections[connection].acquire(block=True) as conn:
print('Got connection: {0!r}'.format(connection.as_uri()))
Note: The block=True here means that the acquire call will block until a connection is available in the pool. Note
that this will block forever in case there is a deadlock in your code where a connection is not released. There is a
timeout argument you can use to safeguard against this (see kombu.connection.Resource.acquire()).
If
blocking
is
disabled
and
there
aren’t
any
connections
left
kombu.exceptions.ConnectionLimitExceeded exception will be raised.
in
the
pool
an
That’s about it. If you need to connect to multiple brokers at once you can do that too:
from kombu import Connection
from kombu.pools import connections
c1 = Connection('amqp://')
c2 = Connection('redis://')
with connections[c1].acquire(block=True) as conn1:
with connections[c2].acquire(block=True) as conn2:
# ....
20
Chapter 2. User Guide
Kombu Documentation, Release 4.0.0a1
2.7.2 The producer pool group
This is a pool group just like the connections, except that it manages Producer instances used to publish messages.
Here is an example using the producer pool to publish a message to the news exchange:
from kombu import Connection, Exchange
from kombu.pools import producers
# The exchange we send our news articles to.
news_exchange = Exchange('news')
# The article we want to send
article = {'title': 'No cellular coverage on the tube for 2012',
'ingress': 'yadda yadda yadda'}
# The broker where our exchange is.
connection = Connection('amqp://guest:guest@localhost:5672//')
with producers[connection].acquire(block=True) as producer:
producer.publish(
article,
exchange=new_exchange,
routing_key='domestic',
declare=[news_exchange],
serializer='json',
compression='zlib')
Setting pool limits
By default every connection instance has a limit of 200 connections. You can change this limit using
kombu.pools.set_limit(). You are able to grow the pool at runtime, but you can’t shrink it, so it is best
to set the limit as early as possible after your application starts:
>>> from kombu import pools
>>> pools.set_limit()
Resetting all pools
You can close all active connections and reset all pool groups by using the kombu.pools.reset() function. Note
that this will not respect anything currently using these connections, so will just drag the connections away from under
their feet: you should be very careful before you use this.
Kombu will reset the pools if the process is forked, so that forked processes start with clean pool groups.
2.7.3 Custom Pool Groups
To maintain your own pool groups you should create your own Connections and kombu.pools.Producers
instances:
from kombu import pools
from kombu import Connection
connections = pools.Connections(limit=100)
producers = pools.Producers(limit=connections.limit)
2.7. Connection and Producer Pools
21
Kombu Documentation, Release 4.0.0a1
connection = Connection('amqp://guest:guest@localhost:5672//')
with connections[connection].acquire(block=True):
# ...
If you want to use the global limit that can be set with set_limit() you can use a special value as the limit
argument:
from kombu import pools
connections = pools.Connections(limit=pools.use_default_limit)
2.8 Serialization
2.8.1 Serializers
By default every message is encoded using JSON, so sending Python data structures like dictionaries and lists works.
YAML, msgpack and Python’s built-in pickle module is also supported, and if needed you can register any custom
serialization scheme you want to use.
By default Kombu will only load JSON messages, so if you want to use other serialization format you must explicitly
enable them in your consumer by using the accept argument:
Consumer(conn, [queue], accept=['json', 'pickle', 'msgpack'])
The accept argument can also include MIME-types.
Each option has its advantages and disadvantages.
json – JSON is supported in many programming languages, is now a standard part of Python (since 2.6), and is
fairly fast to decode using the modern Python libraries such as cjson or simplejson.
The primary disadvantage to JSON is that it limits you to the following data types: strings, Unicode, floats,
boolean, dictionaries, and lists. Decimals and dates are notably missing.
Also, binary data will be transferred using Base64 encoding, which will cause the transferred data to be around
34% larger than an encoding which supports native binary types.
However, if your data fits inside the above constraints and you need cross-language support, the default setting
of JSON is probably your best choice.
pickle – If you have no desire to support any language other than Python, then using the pickle encoding will gain
you the support of all built-in Python data types (except class instances), smaller messages when sending binary
files, and a slight speedup over JSON processing.
Pickle and Security
The pickle format is very convenient as it can serialize and deserialize almost any object, but this is also a
concern for security.
Carefully crafted pickle payloads can do almost anything a regular Python program can do, so if you let your
consumer automatically decode pickled objects you must make sure to limit access to the broker so that untrusted
parties do not have the ability to send messages!
By default Kombu uses pickle protocol 2, but this can be changed using the PICKLE_PROTOCOL environment
variable or by changing the global kombu.serialization.pickle_protocol flag.
22
Chapter 2. User Guide
Kombu Documentation, Release 4.0.0a1
yaml – YAML has many of the same characteristics as json, except that it natively supports more data types (including dates, recursive references, etc.)
However, the Python libraries for YAML are a good bit slower than the libraries for JSON.
If you need a more expressive set of data types and need to maintain cross-language compatibility, then YAML
may be a better fit than the above.
To instruct Kombu to use an alternate serialization method, use one of the following options.
1. Set the serialization option on a per-producer basis:
>>> producer = Producer(channel,
...
exchange=exchange,
...
serializer="yaml")
2. Set the serialization option per message:
>>> producer.publish(message, routing_key=rkey,
...
serializer="pickle")
Note that a Consumer do not need the serialization method specified. They can auto-detect the serialization method as
the content-type is sent as a message header.
2.8.2 Sending raw data without Serialization
In some cases, you don’t need your message data to be serialized. If you pass in a plain string or Unicode object as
your message and a custom content_type, then Kombu will not waste cycles serializing/deserializing the data.
You can optionally specify a content_encoding for the raw data:
>>> with open("~/my_picture.jpg", "rb") as fh:
...
producer.publish(fh.read(),
content_type="image/jpeg",
content_encoding="binary",
routing_key=rkey)
The Message object returned by the Consumer class will have a content_type and content_encoding attribute.
2.8.3 Creating extensions using Setuptools entry-points
A package can also register new serializers using Setuptools entry-points.
The entry-point must provide the name of the serializer along with the path to a tuple providing the rest of the args:
encoder_function, decoder_function, content_type, content_encoding.
An example entrypoint could be:
from setuptools import setup
setup(
entry_points={
'kombu.serializers': [
'my_serializer = my_module.serializer:register_args'
]
}
)
Then the module my_module.serializer would look like:
2.8. Serialization
23
Kombu Documentation, Release 4.0.0a1
register_args = (my_encoder, my_decoder, 'application/x-mimetype', 'utf-8')
When this package is installed the new ‘my_serializer’ serializer will be supported by Kombu.
Buffer Objects
The decoder function of custom serializer must support both strings and Python’s old-style buffer objects.
Python pickle and json modules usually don’t do this via its loads function, but you can easily add support by making
a wrapper around the load function that takes file objects instead of strings.
Here’s an example wrapping pickle.loads() in such a way:
import pickle
from io import BytesIO
from kombu import serialization
def loads(s):
return pickle.load(BytesIO(s))
serialization.register(
'my_pickle', pickle.dumps, loads,
content_type='application/x-pickle2',
content_encoding='binary',
)
24
Chapter 2. User Guide
CHAPTER 3
Frequently Asked Questions
3.1 Questions
3.1.1 Q: Message.reject doesn’t work?
Answer: Earlier versions of RabbitMQ did not implement basic.reject, so make sure your version is recent
enough to support it.
3.1.2 Q: Message.requeue doesn’t work?
Answer: See Message.reject doesn’t work?
25
Kombu Documentation, Release 4.0.0a1
26
Chapter 3. Frequently Asked Questions
CHAPTER 4
API Reference
Release 4.0
Date March 10, 2016
•
•
•
•
•
Connection
Exchange
Queue
Message Producer
Message Consumer
Messaging library for Python
4.1 Connection
4.2 Exchange
Example creating an exchange declaration:
>>> news_exchange = Exchange('news', type='topic')
For now news_exchange is just a declaration, you can’t perform actions on it. It just describes the name and options
for the exchange.
The exchange can be bound or unbound. Bound means the exchange is associated with a channel and operations can
be performed on it. To bind the exchange you call the exchange with the channel as argument:
>>> bound_exchange = news_exchange(channel)
Now you can perform operations like declare() or delete():
>>>
>>>
>>>
>>>
bound_exchange.declare()
message = bound_exchange.Message('Cure for cancer found!')
bound_exchange.publish(message, routing_key='news.science')
bound_exchange.delete()
27
Kombu Documentation, Release 4.0.0a1
4.3 Queue
Example creating a queue using our exchange in the Exchange example:
>>> science_news = Queue('science_news',
...
exchange=news_exchange,
...
routing_key='news.science')
For now science_news is just a declaration, you can’t perform actions on it. It just describes the name and options for
the queue.
The queue can be bound or unbound. Bound means the queue is associated with a channel and operations can be
performed on it. To bind the queue you call the queue instance with the channel as an argument:
>>> bound_science_news = science_news(channel)
Now you can perform operations like declare() or purge():
>>> bound_science_news.declare()
>>> bound_science_news.purge()
>>> bound_science_news.delete()
4.4 Message Producer
4.5 Message Consumer
4.6 Common Utilities - kombu.common
4.7 Mixin Classes - kombu.mixins
4.8 Clocks and Synchronization - kombu.clocks
4.9 kombu.exceptions
Exceptions.
exception kombu.exceptions.NotBoundError
Trying to call channel dependent method on unbound entity.
exception kombu.exceptions.MessageStateError
The message has already been acknowledged.
kombu.exceptions.TimeoutError
alias of timeout
exception kombu.exceptions.LimitExceeded
Limit exceeded.
exception kombu.exceptions.ConnectionLimitExceeded
Maximum number of simultaneous connections exceeded.
exception kombu.exceptions.ChannelLimitExceeded
Maximum number of simultaneous channels exceeded.
28
Chapter 4. API Reference
Kombu Documentation, Release 4.0.0a1
4.10 Logging - kombu.log
4.11 Message Objects - kombu.message
4.12 General Pools - kombu.pools
4.13 Async Utilities - kombu.syn
• kombu.syn
4.13.1 kombu.syn
kombu.syn.detect_environment()
4.10. Logging - kombu.log
29
Kombu Documentation, Release 4.0.0a1
30
Chapter 4. API Reference
Kombu Documentation, Release 4.0.0a1
4.14 Event Loop - kombu.async
4.15 Event Loop Implementation - kombu.async.hub
4.16 Semaphores - kombu.async.semaphore
4.17 Timer - kombu.async.timer
4.18 Debugging Utils - kombu.async.debug
4.19 kombu.transport.zmq
4.20 kombu.transport.zookeeper
4.21 kombu.transport.django
4.22 Django Models - kombu.transport.django.models
4.23 Django Managers - kombu.transport.django.managers
4.24 Django Management - clean_kombu_messages
4.25 kombu.transport.sqlalchemy
4.26 kombu.transport.SLMQ
4.27 Utilities - kombu.utils
4.28 Evented I/O - kombu.utils.eventio
4.29 Rate limiting - kombu.utils.limits
4.30 Debugging - kombu.utils.debug
4.31 String Encoding - kombu.utils.encoding
4.32 kombu.utils.functional
4.33 kombu.utils.url
4.14. Event Loop - kombu.async
4.34 Text utilitites - kombu.utils.text
31
Kombu Documentation, Release 4.0.0a1
32
Chapter 4. API Reference
CHAPTER 5
Change history
5.1 4.0
release-date TBA
• Now depends on amqp 2.0.0.
• No longer depends on anyjson.
• New SQS transport
Donated by NextDoor, with additional contributions from mdk.
• Redis: Priority 0 is now lowest, 9 is highest. (backward incompatible)
This to match how priorities in AMQP works.
Fix contributed by Alex Koshelev.
• Beanstalk: Priority 0 is now lowest, 9 is highest. (backward incompatible)
This to match how priorities in AMQP works.
Fix contributed by Alex Koshelev.
• Redis: now supports SSL using the ssl argument to Connection.
• Redis: Fanout exchanges are no longer visible between vhosts, and fanout messages can be filtered by patterns.
(backward incompatible)
It was possible to enable this mode previously using the fanout_prefix,
fanout_patterns transport options, but now these are enabled by default.
and
If you want to mix and match producers/consumers running different versions you need to configure
your kombu 3.x clients to also enable these options:
>>> Connection(transport_options={
'fanout_prefix': True,
'fanout_patterns': True,
})
• Exchange.delivery_mode now defaults to None, and the default is instead set by Producer.publish.
• Consumer now supports a new prefetch_count argument, which if provided will force the consumer to
set an initial prefetch count just before starting.
• Virtual transports now stores priority as a property, not in delivery_info, to be compatible with AMQP.
• reply_to argument to Producer.publish can now be Queue instance.
33
Kombu Documentation, Release 4.0.0a1
• Connection: There’s now a new method Connection.supports_exchange_type(type) that can be
used to check if the
current transport supports a specific exchange type.
• SQS: Will now log the access key used when authentication fails.
Contributed by Hank John.
• Added new kombu.mixins.ConsumerProducerMixin for consumers that will also publish messages
on a separate connection.
• Messages: Now have a more descriptive repr.
Contributed by Joshua Harlow.
• Async: HTTP client based on curl.
• Async: Now uses poll instead of select where available.
• MongoDB: Now supports priorities
Contributed by Alex Koshelev.
• Zookeeper: Transport now uses the built-in suport in kazoo to handle failover when using a list of server names.
Contributed by Joshua Harlow.
5.2 3.0.28
release-date 2015-10-12 12:00 PM PDT
release-by Ask Solem
:.. admonition:: Django transport migrations.
If you’re using Django 1.8 and have already created the kombu_transport_django tables, you have to run
a fake initial migration:
python manage.py migrate kombu_transport_django --fake-initial
• No longer compatible with South by default.
To keep using kombu.transport.django with South migrations you now need to configure a new location for the kombu migrations:
SOUTH_MIGRATION_MODULES = {
'kombu_transport_django':
'kombu.transport.django.south_migrations',
}
• Keep old South migrations in kombu.transport.django.south_migrations.
• Now works with Redis < 2.10 again.
5.3 3.0.27
release-date 2015-10-09 3:10 PM PDT
release-by Ask Solem
• Now depends on amqp 1.4.7.
34
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
• Fixed libSystem import error on some OS X 10.11 (El Capitan) installations.
Fix contributed by Eric Wang.
• Now compatible with Django 1.9.
• Django: Adds migrations for the database transport.
• Redis: Now depends on py-redis 2.10.0 or later (Issue #468).
• QPid: Can now connect as localhost (Issue #519).
Fix contributed by Brian Bouterse.
• QPid: Adds support for login_method (Issue #502, Issue #499).
Contributed by Brian Bouterse.
• QPid: Now reads SASL mechanism from broker string (Issue #498).
Fix contributed by Brian Bouterse.
• QPid: Monitor thread now properly terminated on session close (Issue #485).
Fix contributed by Brian Bouterse.
• QPid: Fixed file descriptor leak (Issue #476).
Fix contributed by Jeff Ortel
• Docs: Fixed wrong order for entrypoint arguments (Issue #473).
• ConsumerMixin: Connection error logs now include traceback (Issue #480).
• BaseTransport now raises RecoverableConnectionError when disconnected (Issue #507).
• Consumer: Adds tag_prefix option to modify how consumer tags are generated (Issue #509).
5.4 3.0.26
release-date 2015-04-22 06:00 P.M UTC
release-by Ask Solem
• Fixed compatibility with py-redis versions before 2.10.3 (Issue #470).
5.5 3.0.25
release-date 2015-04-21 02:00 P.M UTC
release-by Ask Solem
• pyamqp/librabbitmq now uses 5671 as default port when SSL is enabled (Issue #459).
• Redis: Now supports passwords in redis+socket://:pass@host:port URLs (Issue #460).
• Producer.publish now defines the expiration property in support of the RabbitMQ per-message TTL
extension.
Contributed by Anastasis Andronidis.
• Connection transport attribute now set correctly for all transports.
Contributed by Alex Koshelev.
5.4. 3.0.26
35
Kombu Documentation, Release 4.0.0a1
• qpid: Fixed bug where the connectionw as not being closed properly.
Contributed by Brian Bouterse.
• bindings is now JSON serializable (Issue #453).
Contributed by Sergey Tikhonov.
• Fixed typo in error when yaml is not installed (said msgpack).
Contributed by Joshua Harlow.
• Redis: Now properly handles ‘‘TimeoutError raised by py-redis.
Contributed by markow.
• qpid: Adds additional string to check for when connecting to qpid.
When we connect to qpid, we need to ensure that we skip to the next SASL mechanism if the current
mechanism fails. Otherwise, we will keep retrying the connection with a non-working mech.
Contributed by Chris Duryee.
• qpid: Handle NotFound exceptions.
Contributed by Brian Bouterse.
• Queue.__repr__ now makes sure return value is not unicode (Issue #440).
• qpid: Queue.purge incorrectly raised AttributeErrror if the does not exist (Issue #439).
Contributed by Brian Bouterse.
• Linux: Now ignores permission errors on epoll unregister.
5.6 3.0.24
release-date 2014-11-17 11:00 P.M UTC
release-by Ask Solem
• The Qpid broker is supported for Python 2.x environments. The Qpid transport includes full SSL support within
Kombu. See the kombu.transport.qpid docs for more info.
Contributed by Brian Bouterse and Chris Duryee through support from Red Hat.
• Dependencies: extra[librabbitmq] now requires librabbitmq 1.6.0
• Docstrings for TokenBucket did not match implementation.
Fix contributed by Jesse Dhillon.
• oid_from() accidentally called uuid.getnode() but did not use the return value.
Fix contributed by Alexander Todorov.
• Redis: Now ignores errors when cosing the underlying connection.
• Redis: Restoring messages will now use a single connection.
• kombu.five.monotonic: Can now be imported even if ctypes is not available for some reason (e.g. App
Engine)
• Documentation: Improved example to use the declare argument to Producer (Issue #423).
• Django: Fixed app_label for older Django versions (< 1.7). (Issue #414).
36
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
5.7 3.0.23
release-date 2014-09-14 10:45 P.M UTC
release-by Ask Solem
• Django: Fixed bug in the Django 1.7 compatibility improvements related to autocommit handling.
Contributed by Radek Czajka.
• Django: The Django transport models would not be created on syncdb after app label rename (Issue #406).
5.8 3.0.22
release-date 2014-09-04 03:00 P.M UTC
release-by Ask Solem
• kombu.async: Min. delay between waiting for timer was always increased to one second.
• Fixed bug in itermessages where message is received after the with statement exits the block.
Fixed by Rumyana Neykova
• Connection.autoretry: Now works with functions missing wrapped attributes (__module__,
__name__, __doc__). Fixes #392.
Contributed by johtso.
• Django: Now sets custom app label for kombu.transport.django to work with recent changes in Django
1.7.
• SimpleQueue removed messages from the wrong end of buffer (Issue #380).
• Tests: Now using unittest.mock if available (Issue #381).
5.9 3.0.21
release-date 2014-07-07 02:00 P.M UTC
release-by Ask Solem
• Fixed remaining bug in maybe_declare for auto_delete exchanges.
Fix contributed by Roger Hu.
• MongoDB: Creating a channel now properly evaluates a connection (Issue #363).
Fix contributed by Len Buckens.
5.10 3.0.20
release-date 2014-06-24 02:30 P.M UTC
release-by Ask Solem
• Reverts change in 3.0.17 where maybe_declare caches the declaration of auto_delete queues and exchanges.
Fix contributed by Roger Hu.
5.7. 3.0.23
37
Kombu Documentation, Release 4.0.0a1
• Redis: Fixed race condition when using gevent and the channel is closed.
Fix contributed by Andrew Rodionoff.
5.11 3.0.19
release-date 2014-06-09 03:10 P.M UTC
release-by Ask Solem
• The wheel distribution did not support Python 2.6 by failing to list the extra dependencies required.
• Durable and auto_delete queues/exchanges can be be cached using maybe_declare.
5.12 3.0.18
release-date 2014-06-02 06:00 P.M UTC
release-by Ask Solem
• A typo introduced in 3.0.17 caused kombu.async.hub to crash (Issue #360).
5.13 3.0.17
release-date 2014-06-02 05:00 P.M UTC
release-by Ask Solem
• kombu[librabbitmq] now depends on librabbitmq 1.5.2.
• Async: Event loop now selectively removes file descriptors for the mode it failed in, and keeps others (e.g read
vs write).
Fix contributed by Roger Hu.
• CouchDB: Now works without userid set.
Fix contributed by Latitia M. Haskins.
• SQLAlchemy: Now supports recovery from connection errors.
Contributed by Felix Schwarz.
• Redis: Restore at shutdown now works when ack emulation is disabled.
• kombu.common.eventloop() accidentally swallowed socket errors.
• Adds kombu.utils.url.sanitize_url()
5.14 3.0.16
release-date 2014-05-06 01:00 P.M UTC
release-by Ask Solem
• kombu[librabbitmq] now depends on librabbitmq 1.5.1.
38
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
• Redis: Fixes TypeError problem in unregister (Issue #342).
Fix contributed by Tobias Schottdorf.
• Tests: Some unit tests accidentally required the redis-py library.
Fix contributed by Randy Barlow.
• librabbitmq: Would crash when using an older version of librabbitmq, now emits warning instead.
5.15 3.0.15
release-date 2014-04-15 09:00 P.M UTC
release-by Ask Solem
• Now depends on amqp 1.4.5.
• RabbitMQ 3.3 changes QoS semantics (Issue #339).
See the RabbitMQ release notes here: http://www.rabbitmq.com/blog/2014/04/02/breaking-thingswith-rabbitmq-3-3/
A new connection property has been added that can be used to detect whether the remote server is
using this new QoS behavior:
>>> Connection('amqp://').qos_behavior_matches_spec
False
so if your application depends on the old semantics you can use this to set the apply_global flag
appropriately:
def update_prefetch_count(channel, new_value):
channel.basic_qos(
0, new_value,
not channel.connection.client.qos_behavior_matches_spec,
)
• Users of librabbitmq is encouraged to upgrade to librabbitmq 1.5.0.
The kombu[librabbitmq] extra has been updated to depend on this version.
• Pools: Now takes transport options into account when comparing connections (Issue #333).
• MongoDB: Fixes Python 3 compatibility.
• Async: select: Ignore socket errors when attempting to unregister handles from the loop.
• Pidbox: Can now be configured to use a serializer other than json, but specifying a serializer argument to
Mailbox.
Contributed by Dmitry Malinovsky.
• Message decompression now works with Python 3.
Fix contributed by Adam Gaca.
5.16 3.0.14
release-date 2014-03-19 07:00 P.M UTC
5.15. 3.0.15
39
Kombu Documentation, Release 4.0.0a1
release-by Ask Solem
• MongoDB: Now endures a connection failover (Issue #123).
Fix contributed by Alex Koshelev.
• MongoDB: Fixed KeyError when a replica set member is removed.
Also fixes celery#971 and celery/#898.
Fix contributed by Alex Koshelev.
• MongoDB: Fixed MongoDB broadcast cursor re-initialization bug.
Fix contributed by Alex Koshelev.
• Async: Fixed bug in lax semaphore implementation where in some usage patterns the limit was not honored
correctly.
Fix contributed by Ionel Cristian Mărie.
• Redis: Fixed problem with fanout when using Python 3 (Issue #324).
• Redis: Fixed AttributeError from attempting to close a non-existing connection (Issue #320).
5.17 3.0.13
release-date 2014-03-03 04:00 P.M UTC
release-by Ask Solem
• Redis: Fixed serious race condition that could lead to data loss.
The delivery tags were accidentally set to be an incremental number local to the channel, but the
delivery tags need to be globally unique so that a message can not overwrite an older message in the
backup store.
This change is not backwards incompatible and you are encouraged to update all your system using
a previous version as soon as possible.
• Now depends on amqp 1.4.4.
• Pidbox: Now makes sure message encoding errors are handled by default, so that a custom error handler does
not need to be specified.
• Redis: The fanout exchange can now use AMQP patterns to route and filter messages.
This change is backwards incompatible and must be enabled with the fanout_patterns transport
option:
>>> conn = kombu.Connection('redis://', transport_options={
...
'fanout_patterns': True,
... })
When enabled the exchange will work like an amqp topic exchange if the binding key is a pattern.
This is planned to be default behavior in the future.
• Redis: Fixed cycle no such attribute error.
40
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
5.18 3.0.12
release-date 2014-02-09 03:50 P.M UTC
release-by Ask Solem
• Now depends on amqp 1.4.3.
• Fixes Python 3.4 logging incompatibility (Issue #311).
• Redis: Now properly handles unknown pub/sub messages.
Fix contributed by Sam Stavinoha.
• amqplib: Fixed bug where more bytes were requested from the socket than necessary.
Fix contributed by Ionel Cristian Mărie.
5.19 3.0.11
release-date 2014-02-03 05:00 P.M UTC
release-by Ask Solem
• Now depends on amqp 1.4.2.
• Now always trusts messages of type application/data and application/text or which have an unspecified content
type (Issue #306).
• Compression errors are now handled as decode errors and will trigger the Consumer.on_decode_error
callback if specified.
• New kombu.Connection.get_heartbeat_interval() method that can be used to access the negotiated heartbeat value.
• kombu.common.oid_for no longer uses the MAC address of the host, but instead
UUID4 as a node id.
uses
a
process-wide
This avoids a call to uuid.getnode() at module scope.
• Hub.add: Now normalizes registered fileno.
Contributed by Ionel Cristian Mărie.
• SQS: Fixed bug where the prefetch count limit was not respected.
5.20 3.0.10
release-date 2014-01-17 05:40 P.M UTC
release-by Ask Solem
• Now depends on amqp 1.4.1.
• maybe_declare now raises a “recoverable connection error” if the channel is disconnected instead of a
ChannelError so that the operation can be retried.
• Redis: Consumer.cancel() is now thread safe.
This fixes an issue when using gevent/eventlet and a message is handled after the consumer is canceled resulting in a “message for queue without consumers” error.
5.18. 3.0.12
41
Kombu Documentation, Release 4.0.0a1
• Retry operations would not always respect the interval_start value when calculating the time to sleep for (Issue
#303).
Fix contributed by Antoine Legrand.
• Timer: Fixed “unhashable type” error on Python 3.
• Hub: Do not attempt to unregister operations on an already closed poller instance.
5.21 3.0.9
release-date 2014-01-13 05:30 P.M UTC
release-by Ask Solem
• Now depends on amqp 1.4.0.
• Redis: Basic cancel for fanout based queues now sends a corresponding UNSUBSCRIBE command to the server.
This fixes an issue with pidbox where reply messages could be received after the consumer was
canceled, giving the "message to queue without consumers" error.
• MongoDB: Improved connection string and options handling (Issue #266 + Issue #120).
Contributed by Alex Koshelev.
• SQS: Limit the number of messages when receiving in batch to 10.
This is a hard limit enforced by Amazon so the sqs transport must not exceeed this value.
Fix contributed by Eric Reynolds.
• ConsumerMixin: consume now checks heartbeat every time the socket times out.
Contributed by Dustin J. Mitchell.
• Retry Policy: A max retries of 0 did not retry forever.
Fix contributed by Antoine Legrand.
• Simple: If passing a Queue object the simple utils will now take default routing key from that queue.
Contributed by Fernando Jorge Mota.
• repr(producer) no longer evaluates the underlying channnel.
• Redis:
The map of Redis error classes are now exposed at the module level using the
kombu.transport.redis.get_redis_error_classes() function.
• Async: Hub.close now sets .poller to None.
5.22 3.0.8
release-date 2013-12-16 05:00 P.M UTC
release-by Ask Solem
• Serializer:
loads and dumps now wraps
kombu.exceptions.EncodeError respectively.
exceptions
raised
into
DecodeError
and
Contributed by Ionel Cristian Maries
• Redis: Would attempt to read from the wrong connection if a select/epoll/kqueue exception event happened.
42
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
Fix contributed by Michael Nelson.
• Redis: Disabling ack emulation now works properly.
Fix contributed by Michael Nelson.
• Redis: IOError and OSError are now treated as recoverable connection errors.
• SQS: Improved performance by reading messages in bulk.
Contributed by Matt Wise.
• Connection Pool: Attempting to acquire from a closed pool will now raise RuntimeError.
5.23 3.0.7
release-date 2013-12-02 04:00 P.M UTC
release-by Ask Solem
• Fixes Python 2.6 compatibility.
• Redis: Fixes ‘bad file descriptor’ issue.
5.24 3.0.6
release-date 2013-11-21 04:50 P.M UTC
release-by Ask Solem
• Timer: No longer attempts to hash keyword arguments (Issue #275).
• Async: Did not account for the long type for file descriptors.
Fix contributed by Fabrice Rabaute.
• PyPy: kqueue support was broken.
• Redis: Bad pub/sub payloads no longer crashes the consumer.
• Redis: Unix socket URLs can now specify a virtual host by including it as a query parameter.
Example URL specifying a virtual host using database number 3:
redis+socket:///tmp/redis.sock?virtual_host=3
• kombu.VERSION is now a named tuple.
5.25 3.0.5
release-date 2013-11-15 11:00 P.M UTC
release-by Ask Solem
• Now depends on amqp 1.3.3.
• Redis: Fixed Python 3 compatibility problem (Issue #270).
• MongoDB: Fixed problem with URL parsing when authentication used.
5.23. 3.0.7
43
Kombu Documentation, Release 4.0.0a1
Fix contributed by dongweiming.
• pyamqp: Fixed small issue when publishing the message and the property dictionary was set to None.
Fix contributed by Victor Garcia.
• Fixed problem in repr(LaxBoundedSemaphore).
Fix contributed by Antoine Legrand.
• Tests now passing on Python 3.3.
5.26 3.0.4
release-date 2013-11-08 01:00 P.M UTC
release-by Ask Solem
• common.QoS: decrement_eventually now makes sure the value does not go below 1 if a prefetch count
is enabled.
5.27 3.0.3
release-date 2013-11-04 03:00 P.M UTC
release-by Ask Solem
• SQS: Properly reverted patch that caused delays between messages.
Contributed by James Saryerwinnie
• select: Clear all registerd fds on poller.cloe
• Eventloop: unregister if EBADF raised.
5.28 3.0.2
release-date 2013-10-29 02:00 P.M UTC
release-by Ask Solem
• Now depends on amqp version 1.3.2.
• select: Fixed problem where unregister did not properly remove the fd.
5.29 3.0.1
release-date 2013-10-24 04:00 P.M UTC
release-by Ask Solem
• Now depends on amqp version 1.3.1.
• Redis: New option fanout_keyprefix
44
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
This transport option is recommended for all users as it ensures that broadcast (fanout) messages sent
is only seen by the current virtual host:
Connection('redis://', transport_options={'fanout_keyprefix': True})
However, enabling this means that you cannot send or receive messages from older Kombu versions
so make sure all of your participants are upgraded and have the transport option enabled.
This will be the default behavior in Kombu 4.0.
• Distribution: Removed file requirements/py25.txt.
• MongoDB: Now disables auto_start_request.
• MongoDB: Enables use_greenlets if eventlet/gevent used.
• Pidbox: Fixes problem where expires header was None, which is a value not supported by the amq protocol.
• ConsumerMixin: New consumer_context method for starting the consumer without draining events.
5.30 3.0.0
release-date 2013-10-14 04:00 P.M BST
release-by Ask Solem
• Now depends on amqp version 1.3.
• No longer supports Python 2.5
The minimum Python version supported is now Python 2.6.0 for Python 2, and Python 3.3 for Python
3.
• Dual codebase supporting both Python 2 and 3.
No longer using 2to3, making it easier to maintain support for both versions.
• pickle, yaml and msgpack deserialization is now disabled by default.
This means that Kombu will by default refuse to handle any content type other than json.
Pickle is known to be a security concern as it will happily load any object that is embedded in a
pickle payload, and payloads can be crafted to do almost anything you want. The default serializer
in Kombu is json but it also supports a number of other serialization formats that it will evaluate if
received: including pickle.
It was always assumed that users were educated about the security implications of pickle, but in
hindsight we don’t think users should be expected to secure their services if we have the ability to be
secure by default.
By disabling any content type that the user did not explicitly want enabled we ensure that the user
must be conscious when they add pickle as a serialization format to support.
The other built-in serializers (yaml and msgpack) are also disabled even though they aren’t considered
insecure 1 at this point. Instead they’re disabled so that if a security flaw is found in one of these
libraries in the future, you will only be affected if you have explicitly enabled them.
To have your consumer accept formats other than json you have to explicitly add the wanted formats
to a white-list of accepted content types:
1 The PyYAML library has a yaml.load() function with some of the same security implications as pickle, but Kombu uses the
yaml.safe_load() function which is not known to be affected.
5.30. 3.0.0
45
Kombu Documentation, Release 4.0.0a1
>>> c = Consumer(conn, accept=['json', 'pickle', 'msgpack'])
or when using synchronous access:
>>> msg = queue.get(accept=['json', 'pickle', 'msgpack'])
The accept argument was first supported for consumers in version 2.5.10, and first supported by
Queue.get in version 2.5.15 so to stay compatible with previous versions you can enable the
previous behavior:
>>> from kombu import enable_insecure_serializers
>>> enable_insecure_serializers()
But note that this has global effect, so be very careful should you use it.
• kombu.async: Experimental event loop implementation.
This code was previously in Celery but was moved here to make it easier for async transport implementations.
The API is meant to match the Tulip API which will be included in Python 3.4 as the asyncio
module. It’s not a complete implementation obviously, but the goal is that it will be easy to change
to it once that is possible.
• Utility function kombu.common.ipublish has been removed.
Use Producer(..., retry=True) instead.
• Utility function kombu.common.isend_reply has been removed
Use send_reply(..., retry=True) instead.
• kombu.common.entry_to_queue and kombu.messaging.entry_to_queue has been removed.
Use Queue.from_dict(name, **options) instead.
• Redis: Messages are now restored at the end of the list.
Contributed by Mark Lavin.
• StdConnectionError and StdChannelError is removed and
amqp.ChannelError is used instead.
amqp.ConnectionError
and
• Message object implementation has moved to kombu.message.Message.
• Serailization: Renamed functions encode/decode to dumps() and loads().
For backward compatibility the old names are still available as aliases.
• The kombu.log.anon_logger function has been removed.
Use get_logger() instead.
• queue_declare now returns namedtuple with queue, message_count, and consumer_count fields.
• LamportClock: Can now set lock class
• kombu.utils.clock: Utilities for ordering events added.
• SimpleQueue now allows you to override the exchange type used.
Contributed by Vince Gonzales.
• Zookeeper transport updated to support new changes in the kazoo library.
Contributed by Mahendra M.
46
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
• pyamqp/librabbitmq: Transport options are now forwarded as keyword arguments to
connection (Issue #214).
the
underlying
• Transports may now distinguish between recoverable and irrecoverable connection and channel errors.
• kombu.utils.Finalize has been removed: Use multiprocessing.util.Finalize instead.
• Memory transport now supports the fanout exchange type.
Contributed by Davanum Srinivas.
• Experimental new Pyro transport (kombu.transport.pyro).
Contributed by Tommie McAfee.
• Experimental new SoftLayer MQ transport (kombu.transport.SLMQ).
Contributed by Kevin McDonald
• Eventio: Kqueue breaks in subtle ways so select is now used instead.
• SQLAlchemy transport:
Can now specify table names using the queue_tablename and
message_tablename transport options.
Contributed by Ryan Petrello.
Redis transport: Now supports using local UNIX sockets to communicate with the Redis server (Issue #1283)
To connect using a UNIX socket you have to use the redis+socket URL-prefix:
redis+socket:///tmp/redis.sock.
This functionality was merged from the celery-redis-unixsocket project. Contributed by Maxime
Rouyrre.
ZeroMQ transport: drain_events now supports timeout.
Contributed by Jesper Thomschütz.
5.31 2.5.16
release-date 2013-10-04 03:30 P.M BST
release-by Ask Solem
• Python 3: Fixed problem with dependencies not being installed.
5.32 2.5.15
release-date 2013-10-04 03:30 P.M BST
release-by Ask Solem
• Declaration cache: Now only keeps hash of declaration so that it does not keep a reference to the channel.
• Declaration cache: Now respects entity.can_cache_declaration attribute.
• Fixes Python 2.5 compatibility.
• Fixes tests after python-msgpack changes.
• Queue.get: Now supports accept argument.
5.31. 2.5.16
47
Kombu Documentation, Release 4.0.0a1
5.33 2.5.14
release-date 2013-08-23 05:00 P.M BST
release-by Ask Solem
• safe_str did not work properly resulting in UnicodeDecodeError (Issue #248).
5.34 2.5.13
release-date 2013-08-16 04:00 P.M BST
release-by Ask Solem
• Now depends on amqp 1.0.13
• Fixed typo in Django functional tests.
• safe_str now returns Unicode in Python 2.x
Fix contributed by Germán M. Bravo.
• amqp: Transport options are now merged with arguments supplied to the connection.
• Tests no longer depends on distribute, which was deprecated and merged back into setuptools.
Fix contributed by Sascha Peilicke.
• ConsumerMixin now also restarts on channel related errors.
Fix contributed by Corentin Ardeois.
5.35 2.5.12
release-date 2013-06-28 03:30 P.M BST
release-by Ask Solem
• Redis: Ignore errors about keys missing in the round-robin cycle.
• Fixed test suite errors on Python 3.
• Fixed msgpack test failures.
5.36 2.5.11
release-date 2013-06-25 02:30 P.M BST
release-by Ask Solem
• Now depends on amqp 1.0.12 (Py3 compatibility issues).
• MongoDB: Removed cause of a “database name in URI is being ignored” warning.
Fix by Flavio Percoco Premoli
• Adds passive option to Exchange.
48
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
Setting this flag means that the exchange will not be declared by kombu, but that it must exist already
(or an exception will be raised).
Contributed by Rafal Malinowski
• Connection.info() now gives the current hostname and not the list of available hostnames.
Fix contributed by John Shuping.
• pyamqp: Transport options are now forwarded as kwargs to amqp.Connection.
• librabbitmq: Transport options are now forwarded as kwargs to librabbitmq.Connection.
• librabbitmq: Now raises NotImplementedError if SSL is enabled.
The librabbitmq library does not support ssl, but you can use stunnel or change to the pyamqp://
transport instead.
Fix contributed by Dan LaMotte.
• librabbitmq: Fixed a cyclic reference at connection close.
• eventio: select implementation now removes bad file descriptors.
• eventio: Fixed Py3 compatibility problems.
• Functional tests added for py-amqp and librabbitmq transports.
• Resource.force_close_all no longer uses a mutex.
• Pidbox: Now ignores IconsistencyError when sending replies, as this error simply means that the client may no
longer be alive.
• Adds new Connection.collect method, that can be used to clean up after connections without I/O.
• queue_bind is no longer called for queues bound to the “default exchange” (Issue #209).
Contributed by Jonathan Halcrow.
• The max_retries setting for retries was not respected correctly (off by one).
5.37 2.5.10
release-date 2013-04-11 06:10 P.M BST
release-by Ask Solem
5.37.1 Note about upcoming changes for Kombu 3.0
Kombu 3 consumers will no longer accept pickle/yaml or msgpack by default, and you will have to explicitly enable untrusted deserializers either globally using kombu.enable_insecure_serializers(), or using the
accept argument to Consumer.
5.37.2 Changes
• New utility function to disable/enable untrusted serializers.
– kombu.disable_insecure_serializers()
– kombu.enable_insecure_serializers().
5.37. 2.5.10
49
Kombu Documentation, Release 4.0.0a1
• Consumer: accept can now be used to specify a whitelist of content types to accept.
If the accept whitelist is set and a message is received with a content type that is not in the whitelist
then a ContentDisallowed exception is raised. Note that this error can be handled by the already
existing on_decode_error callback
Examples:
Consumer(accept=['application/json'])
Consumer(accept=['pickle', 'json'])
• Now depends on amqp 1.0.11
• pidbox: Mailbox now supports the accept argument.
• Redis: More friendly error for when keys are missing.
• Connection URLs: The parser did not work well when there were multiple ‘+’ tokens.
5.38 2.5.9
release-date 2013-04-08 05:07 P.M BST
release-by Ask Solem
• Pidbox: Now warns if there are multiple nodes consuming from the same pidbox.
• Adds Queue.on_declared
A callback to be called when the queue is declared, with signature (name, messages,
consumers).
• Now uses fuzzy matching to suggest alternatives to typos in transport names.
• SQS: Adds new transport option queue_prefix.
Contributed by j0hnsmith.
• pyamqp: No longer overrides verify_connection.
• SQS: Now specifies the driver_type and driver_name attributes.
Fix contributed by Mher Movsisyan.
• Fixed bug with kombu.utils.retry_over_time when no errback specified.
5.39 2.5.8
release-date 2013-03-21 04:00 P.M UTC
release-by Ask Solem
• Now depends on amqp 1.0.10 which fixes a Python 3 compatibility error.
• Redis: Fixed a possible race condition (Issue #171).
• Redis: Ack emulation/visibility_timeout can now be disabled using a transport option.
Ack emulation adds quite a lot of overhead to ensure data is safe even in the event of an unclean
shutdown. If data loss do not worry you there is now an ack_emulation transport option you can use
to disable it:
50
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
Connection('redis://', transport_options={'ack_emulation': False})
• SQS: Fixed boto v2.7 compatibility (Issue #207).
• Exchange: Should not try to re-declare default exchange ("") (Issue #209).
• SQS: Long polling is now disabled by default as it was not implemented correctly, resulting in long delays
between receiving messages (Issue #202).
• Fixed Python 2.6 incompatibility depending on exc.errno being available.
Fix contributed by Ephemera.
5.40 2.5.7
release-date 2013-03-08 01:00 P.M UTC
release-by Ask Solem
• Now depends on amqp 1.0.9
• Redis: A regression in 2.5.6 caused the redis transport to ignore options set in transport_options.
• Redis: New socket_timeout transport option.
• Redis: InconsistencyError is now regarded as a recoverable error.
• Resource pools: Will no longer attempt to release resource that was never acquired.
• MongoDB: Now supports the ssl option.
Contributed by Sebastian Pawlus.
5.41 2.5.6
release-date 2013-02-08 01:00 P.M UTC
release-by Ask Solem
• Now depends on amqp 1.0.8 which works around a bug found on some Python 2.5 installations where 2**32
overflows to 0.
5.42 2.5.5
release-date 2013-02-07 05:00 P.M UTC
release-by Ask Solem
SQS: Now supports long polling (Issue #176).
The polling interval default has been changed to 0 and a new transport option (wait_time_seconds)
has been added. This parameter specifies how long to wait for a message from SQS, and defaults to 20
seconds, which is the maximum value currently allowed by Amazon SQS.
Contributed by James Saryerwinnie.
• SQS: Now removes unpickleable fields before restoring messages.
5.40. 2.5.7
51
Kombu Documentation, Release 4.0.0a1
• Consumer.__exit__ now ignores exceptions occurring while canceling the consumer.
• Virtual: Routing keys can now consist of characters also used in regular expressions (e.g. parens) (Issue #194).
• Virtual: Fixed compression header when restoring messages.
Fix contributed by Alex Koshelev.
• Virtual: ack/reject/requeue now works while using basic_get.
• Virtual: Message.reject is now supported by virtual transports (requeue depends on individual transport support).
• Fixed typo in hack used for static analyzers.
Fix contributed by Basil Mironenko.
5.43 2.5.4
release-date 2012-12-10 12:35 P.M UTC
release-by Ask Solem
• Fixed problem with connection clone and multiple URLs (Issue #182).
Fix contributed by Dane Guempel.
• zeromq: Now compatible with libzmq 3.2.x.
Fix contributed by Andrey Antukh.
• Fixed Python 3 installation problem (Issue #187).
5.44 2.5.3
release-date 2012-11-29 12:35 P.M UTC
release-by Ask Solem
• Pidbox: Fixed compatibility with Python 2.6
5.45 2.5.2
release-date 2012-11-29 12:35 P.M UTC
release-by Ask Solem
5.46 2.5.2
release-date 2012-11-29 12:35 P.M UTC
release-by Ask Solem
• [Redis] Fixed connection leak and added a new ‘max_connections’ transport option.
52
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
5.47 2.5.1
release-date 2012-11-28 12:45 P.M UTC
release-by Ask Solem
• Fixed bug where return value of Queue.as_dict could not be serialized with JSON (Issue #177).
5.48 2.5.0
release-date 2012-11-27 04:00 P.M UTC
release-by Ask Solem
• py-amqp is now the new default transport, replacing amqplib.
The new py-amqp library is a fork of amqplib started with the following goals:
– Uses AMQP 0.9.1 instead of 0.8
– Support for heartbeats (Issue #79 + Issue #131)
– Automatically revives channels on channel errors.
– Support for all RabbitMQ extensions
* Consumer Cancel Notifications (Issue #131)
* Publisher Confirms (Issue #131).
* Exchange-to-exchange bindings: exchange_bind / exchange_unbind.
– API compatible with librabbitmq so that it can be used as a pure-python replacement in
environments where rabbitmq-c cannot be compiled. librabbitmq will be updated to support all
the same features as py-amqp.
• Support for using multiple connection URL’s for failover.
The first argument to Connection can now be a list of connection URLs:
Connection(['amqp://foo', 'amqp://bar'])
or it can be a single string argument with several URLs separated by semicolon:
Connection('amqp://foo;amqp://bar')
There is also a new keyword argument failover_strategy that defines how
ensure_connection()/ ensure()/kombu.Connection.autoretry() will reconnect
in the event of connection failures.
The default reconnection strategy is round-robin, which will simply cycle through the list forever,
and there’s also a shuffle strategy that will select random hosts from the list. Custom strategies
can also be used, in that case the argument must be a generator yielding the URL to connect to.
Example:
Connection('amqp://foo;amqp://bar')
• Now supports PyDev, PyCharm, pylint and other static code analysis tools.
• Queue now supports multiple bindings.
5.47. 2.5.1
53
Kombu Documentation, Release 4.0.0a1
You can now have multiple bindings in the same queue by having the second argument be a list:
from kombu import binding, Queue
Queue('name', [
binding(Exchange('E1'), routing_key='foo'),
binding(Exchange('E1'), routing_key='bar'),
binding(Exchange('E2'), routing_key='baz'),
])
To enable this, helper methods have been added:
– bind_to()
– unbind_from()
Contributed by Rumyana Neykova.
• Custom serializers can now be registered using Setuptools entry-points.
See Creating extensions using Setuptools entry-points.
• New kombu.common.QoS class used as a thread-safe way to manage changes to a consumer or channels
prefetch_count.
This was previously an internal class used in Celery now moved to the kombu.common module.
• Consumer now supports a on_message callback that can be used to process raw messages (not decoded).
Other callbacks specified using the callbacks argument, and the receive method will be not
be called when a on message callback is present.
• New utility kombu.common.ignore_errors() ignores connection and channel errors.
Must only be used for cleanup actions at shutdown or on connection loss.
• Support for exchange-to-exchange bindings.
The Exchange entity gained bind_to and unbind_from methods:
e1 = Exchange('A')(connection)
e2 = Exchange('B')(connection)
e2.bind_to(e1, routing_key='rkey', arguments=None)
e2.unbind_from(e1, routing_key='rkey', arguments=None)
This is currently only supported by the pyamqp transport.
Contributed by Rumyana Neykova.
5.49 2.4.10
release-date 2012-11-22 06:00 P.M UTC
release-by Ask Solem
• The previous versions connection pool changes broke Redis support so that it would always connect to localhost
(default setting) no matter what connection parameters were provided (Issue #176).
54
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
5.50 2.4.9
release-date 2012-11-21 03:00 P.M UTC
release-by Ask Solem
• Redis: Fixed race condition that could occur while trying to restore messages (Issue #171).
Fix contributed by Ollie Walsh.
• Redis: Each channel is now using a specific connection pool instance, which is disconnected on connection
failure.
• ProducerPool: Fixed possible dead-lock in the acquire method.
• ProducerPool: force_close_all no longer tries to call the non-existent Producer._close.
• librabbitmq: Now implements transport.verify_connection so that connection pools will not give
back connections that are no longer working.
• New and better repr() for Queue and Exchange objects.
• Python 3: Fixed problem with running the unit test suite.
• Python 3: Fixed problem with JSON codec.
5.51 2.4.8
release-date 2012-11-02 05:00 P.M UTC
release-by Ask Solem
• Redis: Improved fair queue cycle implementation (Issue #166).
Contributed by Kevin McCarthy.
• Redis: Unacked message restore limit is now unlimited by default.
Also, the limit can now be configured using the unacked_restore_limit transport option:
Connection('redis://', transport_options={
'unacked_restore_limit': 100,
})
A limit of 100 means that the consumer will restore at most 100
messages at each pass.
• Redis: Now uses a mutex to ensure only one consumer restores messages at a time.
The mutex expires after 5 minutes by default,
unacked_mutex_expire transport option.
but can be configured using the
• LamportClock.adjust now returns the new clock value.
• Heartbeats can now be specified in URLs.
Fix contributed by Mher Movsisyan.
• Kombu can now be used with PyDev, PyCharm and other static analysis tools.
• Fixes problem with msgpack on Python 3 (Issue #162).
Fix contributed by Jasper Bryant-Greene
5.50. 2.4.9
55
Kombu Documentation, Release 4.0.0a1
• amqplib: Fixed bug with timeouts when SSL is used in non-blocking mode.
Fix contributed by Mher Movsisyan
5.52 2.4.7
release-date 2012-09-18 03:00 P.M BST
release-by Ask Solem
• Virtual: Unknown exchanges now default to ‘direct’ when sending a message.
• MongoDB: Fixed memory leak when merging keys stored in the db (Issue #159)
Fix contributed by Michael Korbakov.
• MongoDB: Better index for MongoDB transport (Issue #158).
This improvement will create a new compund index for queue and _id in order to be able to use both
indexed fields for getting a new message (using queue field) and sorting by _id. It’ll be necessary to
manually delete the old index from the collection.
Improvement contributed by rmihael
5.53 2.4.6
release-date 2012-09-12 03:00 P.M BST
release-by Ask Solem
• Adds additional compatibility dependencies:
– Python <= 2.6:
* importlib
* ordereddict
– Python <= 2.5
* simplejson
5.54 2.4.5
release-date 2012-08-30 03:36 P.M BST
release-by Ask Solem
• Last version broke installtion on PyPy and Jython due to test requirements clean-up.
5.55 2.4.4
release-date 2012-08-29 04:00 P.M BST
release-by Ask Solem
• amqplib: Fixed a bug with asynchronously reading large messages.
56
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
• pyamqp: Now requires amqp 0.9.3
• Cleaned up test requirements.
5.56 2.4.3
release-date 2012-08-25 10:30 P.M BST
release-by Ask Solem
• Fixed problem with amqp transport alias (Issue #154).
5.57 2.4.2
release-date 2012-08-24 05:00 P.M BST
release-by Ask Solem
• Having an empty transport name broke in 2.4.1.
5.58 2.4.1
release-date 2012-08-24 04:00 P.M BST
release-by Ask Solem
• Redis: Fixed race condition that could cause the consumer to crash (Issue #151)
Often leading to the error message "could not convert string to float"
• Connection retry could cause an inifite loop (Issue #145).
• The amqp alias is now resolved at runtime, so that eventlet detection works even if patching was done later.
5.59 2.4.0
release-date 2012-08-17 08:00 P.M BST
release-by Ask Solem
• New experimental ZeroMQ <kombu.transport.zmq transport.
Contributed by John Watson.
• Redis: Ack timed-out messages were not restored when using the eventloop.
• Now uses pickle protocol 2 by default to be cross-compatible with Python 3.
The protocol can also now be changed using the PICKLE_PROTOCOL environment variable.
• Adds Transport.supports_ev attribute.
• Pika: Queue purge was not working properly.
Fix contributed by Steeve Morin.
• Pika backend was no longer working since Kombu 2.3
5.56. 2.4.3
57
Kombu Documentation, Release 4.0.0a1
Fix contributed by Steeve Morin.
5.60 2.3.2
release-date 2012-08-01 06:00 P.M BST
release-by Ask Solem
• Fixes problem with deserialization in Python 3.
5.61 2.3.1
release-date 2012-08-01 04:00 P.M BST
release-by Ask Solem
• librabbitmq: Can now handle messages that does not have a content_encoding/content_type set (Issue #149).
Fix contributed by C Anthony Risinger.
• Beanstalk: Now uses localhost by default if the URL does not contain a host.
5.62 2.3.0
release-date 2012-07-24 03:50 P.M BST
release-by Ask Solem
• New pyamqp:// transport!
The new py-amqp library is a fork of amqplib started with the following goals:
– Uses AMQP 0.9.1 instead of 0.8
– Should support all RabbitMQ extensions
– API compatible with librabbitmq so that it can be used as a pure-python replacement in
environments where rabbitmq-c cannot be compiled.
If you start using use py-amqp instead of amqplib you can enjoy many advantages including:
– Heartbeat support (Issue #79 + Issue #131)
– Consumer Cancel Notifications (Issue #131)
– Publisher Confirms
amqplib has not been updated in a long while, so maintaining our own fork ensures that we can
quickly roll out new features and fixes without resorting to monkey patching.
To use the py-amqp transport you must install the amqp library:
$ pip install amqp
and change the connection URL to use the correct transport:
>>> conn = Connection('pyamqp://guest:guest@localhost//')
58
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
The pyamqp:// transport will be the default fallback transport in Kombu version 3.0, when
librabbitmq is not installed, and librabbitmq will also be updated to support the same features.
• Connection now supports heartbeat argument.
If enabled you must make sure to manually maintain heartbeats by calling
Connection.heartbeat_check at twice the rate of the specified heartbeat interval.
the
E.g.
if you have Connection(heartbeat=10),
Connection.heartbeat_check() every 5 seconds.
call
then
you
must
if the server has not sent heartbeats at a suitable rate then the heartbeat check method must raise an
error that is listed in Connection.connection_errors.
The attribute Connection.supports_heartbeats has been added for the ability to inspect
if a transport supports heartbeats or not.
Calling heartbeat_check on a transport that does not support heartbeats results in a noop operation.
• SQS: Fixed bug with invalid characters in queue names.
Fix contributed by Zach Smith.
• utils.reprcall: Fixed typo where kwargs argument was an empty tuple by default, and not an empty dict.
5.63 2.2.6
release-date 2012-07-10 05:00 P.M BST
release-by Ask Solem
• Adds kombu.messaging.entry_to_queue for compat with previous versions.
5.64 2.2.5
release-date 2012-07-10 05:00 P.M BST
release-by Ask Solem
• Pidbox: Now sets queue expire at 10 seconds for reply queues.
• EventIO: Now ignores ValueError raised by epoll unregister.
• MongoDB: Fixes Issue #142
Fix by Flavio Percoco Premoli
5.65 2.2.4
release-date 2012-07-05 04:00 P.M BST
release-by Ask Solem
• Support for msgpack-python 0.2.0 (Issue #143)
5.63. 2.2.6
59
Kombu Documentation, Release 4.0.0a1
The latest msgpack version no longer supports Python 2.5, so if you’re still using that you need to
depend on an earlier msgpack-python version.
Fix contributed by Sebastian Insua
• maybe_declare() no longer caches entities with the auto_delete flag set.
• New experimental filesystem transport.
Contributed by Bobby Beever.
• Virtual Transports: Now support anonymous queues and exchanges.
5.66 2.2.3
release-date 2012-06-24 05:00 P.M BST
release-by Ask Solem
• BrokerConnection now renamed to Connection.
The name Connection has been an alias for a very long time, but now the rename is official in the
documentation as well.
The Connection alias has been available since version 1.1.3, and BrokerConnection will still
work and is not deprecated.
• Connection.clone() now works for the sqlalchemy transport.
• kombu.common.eventloop(), kombu.utils.uuid(), and kombu.utils.url.parse_url()
can now be imported from the kombu module directly.
• Pidbox transport callback after_reply_message_received now happens in a finally block.
• Trying to use the librabbitmq:// transport will now show the right name in the ImportError if
librabbitmq is not installed.
The librabbitmq falls back to the older pylibrabbitmq name for compatibility reasons and would
therefore show No module named pylibrabbitmq instead of librabbitmq.
5.67 2.2.2
release-date 2012-06-22 02:30 P.M BST
release-by Ask Solem
• Now depends on anyjson 0.3.3
• Json serializer: Now passes buffer objects directly, since this is supported in the latest anyjson version.
• Fixes blocking epoll call if timeout was set to 0.
Fix contributed by John Watson.
• setup.py now takes requirements from the requirements/ directory.
• The distribution directory contrib/ is now renamed to extra/
60
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
5.68 2.2.1
release-date 2012-06-21 01:00 P.M BST
release-by Ask Solem
• SQS: Default visibility timeout is now 30 minutes.
Since we have ack emulation the visibility timeout is only in effect if the consumer is abrubtly terminated.
• retry argument to Producer.publish now works properly, when the declare argument is specified.
• Json serializer: didn’t handle buffer objects (Issue #135).
Fix contributed by Jens Hoffrichter.
• Virtual: Now supports passive argument to exchange_declare.
• Exchange & Queue can now be bound to connections (which will use the default channel):
>>> exchange = Exchange('name')
>>> bound_exchange = exchange(connection)
>>> bound_exchange.declare()
• SimpleQueue & SimpleBuffer can now be bound to connections (which will use the default channel).
• Connection.manager.get_bindings now works for librabbitmq and pika.
• Adds new transport info attributes:
- ``Transport.driver_type``
Type of underlying driver, e.g. "amqp", "redis", "sql".
- ``Transport.driver_name``
Name of library used e.g. "amqplib", "redis", "pymongo".
- ``Transport.driver_version()``
Version of underlying library.
5.69 2.2.0
release-date 2012-06-07 03:10 P.M BST
release-by Ask Solem
5.69.1 Important Notes
• The canonical source code repository has been moved to
http://github.com/celery/kombu
• Pidbox: Exchanges used by pidbox are no longer auto_delete.
5.68. 2.2.1
61
Kombu Documentation, Release 4.0.0a1
Auto delete has been described as a misfeature, and therefore we have disabled it.
For RabbitMQ users old exchanges used by pidbox must be removed, these are named
mailbox_name.pidbox, and reply.mailbox_name.pidbox.
The following command can be used to clean up these exchanges:
VHOST=/ URL=amqp:// python -c'import sys,kombu;[kombu.Connection(
sys.argv[-1]).channel().exchange_delete(x)
for x in sys.argv[1:-1]]' \
$(sudo rabbitmqctl -q list_exchanges -p "$VHOST" \
| grep \.pidbox | awk '{print $1}') "$URL"
The VHOST variable must be set to the target RabbitMQ virtual host, and the URL must be the AMQP
URL to the server.
• The amqp transport alias will now use librabbitmq if installed.
py-librabbitmq is a fast AMQP client for Python using the librabbitmq C library.
It can be installed by:
$ pip install librabbitmq
It will not be used if the process is monkey patched by eventlet/gevent.
5.69.2 News
• Redis: Ack emulation improvements.
Reducing the possibility of data loss.
Acks are now implemented by storing a copy of the message when the message is consumed. The
copy is not removed until the consumer acknowledges or rejects it.
This means that unacknowledged messages will be redelivered either when the connection is closed,
or when the visibility timeout is exceeded.
– Visibility timeout
This is a timeout for acks, so that if the consumer does not ack the message within this
time limit, the message is redelivered to another consumer.
The timeout is set to one hour by default, but can be changed by configuring a transport
option:
>>> Connection('redis://', transport_options={
...
'visibility_timeout': 1800, # 30 minutes
... })
NOTE: Messages that have not been acked will be redelivered if the visibility timeout is exceeded,
for Celery users this means that ETA/countdown tasks that are scheduled to execute with a time
that exceeds the visibility timeout will be executed twice (or more). If you plan on using long
ETA/countdowns you should tweak the visibility timeout accordingly:
BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 18000}
# 5 hours
Setting a long timeout means that it will take a long time for messages to be redelivered in the event
of a power failure, but if so happens you could temporarily set the visibility timeout lower to flush
out messages when you start up the systems again.
62
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
• Experimental Apache ZooKeeper transport
More information is in the module reference: kombu.transport.zookeeper.
Contributed by Mahendra M.
• Redis: Priority support.
The message’s priority field is now respected by the Redis transport by having multiple lists for
each named queue. The queues are then consumed by in order of priority.
The priority field is a number in the range of 0 - 9, where 0 is the default and highest priority.
The priority range is collapsed into four steps by default, since it is unlikely that nine steps will
yield more benefit than using four steps. The number of steps can be configured by setting the
priority_steps transport option, which must be a list of numbers in sorted order:
>>> x = Connection('redis://', transport_options={
...
'priority_steps': [0, 2, 4, 6, 8, 9],
... })
Priorities implemented in this way is not as reliable as priorities on the server side, which is why
nickname the feature “quasi-priorities”; Using routing is still the suggested way of ensuring quality of service, as client implemented priorities fall short in a number of ways, e.g. if the worker is
busy with long running tasks, has prefetched many messages, or the queues are congested.
Still, it is possible that using priorities in combination with routing can be more beneficial than using
routing or priorities alone. Experimentation and monitoring should be used to prove this.
Contributed by Germán M. Bravo.
• Redis: Now cycles queues so that consuming is fair.
This ensures that a very busy queue won’t block messages from other queues, and ensures that all
queues have an equal chance of being consumed from.
This used to be the case before, but the behavior was accidentally changed while switching to using
blocking pop.
• Redis: Auto delete queues that are bound to fanout exchanges is now deleted at channel.close.
• amqplib: Refactored the drain_events implementation.
• Pidbox: Now uses connection.default_channel.
• Pickle serialization: Can now decode buffer objects.
• Exchange/Queue declarations can now be cached even if the entity is non-durable.
This is possible because the list of cached declarations are now kept with the connection, so that the
entities will be redeclared if the connection is lost.
• Kombu source code now only uses one-level of explicit relative imports.
5.69.3 Fixes
• eventio: Now ignores ENOENT raised by epoll.register, and EEXIST from epoll.unregister.
• eventio: kqueue now ignores KeyError on unregister.
• Redis: Message.reject now supports the requeue argument.
• Redis: Remove superfluous pipeline call.
Fix contributed by Thomas Johansson.
5.69. 2.2.0
63
Kombu Documentation, Release 4.0.0a1
• Redis: Now sets redelivered header for redelivered messages.
• Now always makes sure references to sys.exc_info() is removed.
• Virtual: The compression header is now removed before restoring messages.
• More tests for the SQLAlchemy backend.
Contributed by Franck Cuny.
• Url parsing did not handle MongoDB URLs properly.
Fix contributed by Flavio Percoco Premoli.
• Beanstalk: Ignore default tube when reserving.
Fix contributed by Zhao Xiaohong.
5.69.4 Nonblocking consume support
librabbitmq, amqplib and redis transports can now be used non-blocking.
The interface is very manual, and only consuming messages is non-blocking so far.
The API should not be regarded as stable or final in any way. It is used by Celery which has very limited needs at this
point. Hopefully we can introduce a proper callback-based API later.
• Transport.eventmap
Is a map of fd -> callback(fileno, event) to register in an eventloop.
• Transport.on_poll_start()
Is called before every call to poll. The poller must support register(fd, callback) and
unregister(fd) methods.
• Transport.on_poll_start(poller)
Called when the hub is initialized.
kombu.utils.eventio.poll.
The poller argument must support the same interface as
• Connection.ensure_connection now takes a callback argument which is called for every loop while
the connection is down.
• Adds connection.drain_nowait
This is a non-blocking alternative to drain_events, but only supported by amqplib/librabbitmq.
• drain_events now sets connection.more_to_read if there is more data to read.
This is to support eventloops where other things must be handled between draining events.
5.70 2.1.8
release-date 2012-05-06 03:06 P.M BST
release-by Ask Solem
• Bound Exchange/Queue’s are now pickleable.
• Consumer/Producer can now be instantiated without a channel,
.revive(channel).
and only later bound using
• ProducerPool now takes Producer argument.
64
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
• fxrange() now counts forever if the stop argument is set to None. (fxrange is like xrange but for decimals).
• Auto delete support for virtual transports were incomplete and could lead to problems so it was removed.
• Cached declarations (maybe_declare()) are now bound to the underlying connection, so that entities are
redeclared if the connection is lost.
This also means that previously uncacheable entities (e.g. non-durable) can now be cached.
• compat ConsumerSet: can now specify channel.
5.71 2.1.7
release-date 2012-04-27 06:00 P.M BST
release-by Ask Solem
• compat consumerset now accepts optional channel argument.
5.72 2.1.6
release-date 2012-04-23 01:30 P.M BST
release-by Ask Solem
• SQLAlchemy transport was not working correctly after URL parser change.
• maybe_declare now stores cached declarations per underlying connection instead of globally, in the rare case
that data disappears from the broker after connection loss.
• Django: Added South migrations.
Contributed by Joseph Crosland.
5.73 2.1.5
release-date 2012-04-13 03:30 P.M BST
release-by Ask Solem
• The url parser removed more than the first leading slash (Issue #121).
• SQLAlchemy: Can now specify url using + separator
Example:
Connection('sqla+mysql://localhost/db')
• Better support for anonymous queues (Issue #116).
Contributed by Michael Barrett.
• Connection.as_uri now quotes url parts (Issue #117).
• Beanstalk: Can now set message TTR as a message property.
Contributed by Andrii Kostenko
5.71. 2.1.7
65
Kombu Documentation, Release 4.0.0a1
5.74 2.1.4
release-date 2012-04-03 04:00 P.M GMT
release-by Ask Solem
• MongoDB: URL parsing are now delegated to the pymongo library (Fixes Issue #103 and Issue #87).
Fix contributed by Flavio Percoco Premoli and James Sullivan
• SQS: A bug caused SimpleDB to be used even if sdb persistence was not enabled (Issue #108).
Fix contributed by Anand Kumria.
• Django: Transaction was committed in the wrong place, causing data cleanup to fail (Issue #115).
Fix contributed by Daisuke Fujiwara.
• MongoDB: Now supports replica set URLs.
Contributed by Flavio Percoco Premoli.
• Redis: Now raises a channel error if a queue key that is currently being consumed from disappears.
Fix contributed by Stephan Jaekel.
• All transport ‘channel_errors’ lists now includes kombu.exception.StdChannelError.
• All kombu exceptions now inherit from a common KombuError.
5.75 2.1.3
release-date 2012-03-20 03:00 P.M GMT
release-by Ask Solem
• Fixes Jython compatibility issues.
• Fixes Python 2.5 compatibility issues.
5.76 2.1.2
release-date 2012-03-01 01:00 P.M GMT
release-by Ask Solem
• amqplib: Last version broke SSL support.
5.77 2.1.1
release-date 2012-02-24 02:00 P.M GMT
release-by Ask Solem
• Connection URLs now supports encoded characters.
• Fixed a case where connection pool could not recover from connection loss.
Fix contributed by Florian Munz.
66
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
• We now patch amqplib’s __del__ method to skip trying to close the socket if it is not connected, as this
resulted in an annoying warning.
• Compression can now be used with binary message payloads.
Fix contributed by Steeve Morin.
5.78 2.1.0
release-date 2012-02-04 10:38 P.M GMT
release-by Ask Solem
• MongoDB: Now supports fanout (broadcast) (Issue #98).
Contributed by Scott Lyons.
• amqplib: Now detects broken connections by using MSG_PEEK.
• pylibrabbitmq: Now supports basic_get (Issue #97).
• gevent: Now always uses the select polling backend.
• pika transport: Now works with pika 0.9.5 and 0.9.6dev.
The old pika transport (supporting 0.5.x) is now available as alias oldpika.
(Note terribly latency has been experienced with the new pika versions, so this is still an experimental
transport).
• Virtual transports: can now set polling interval via the transport options (Issue #96).
Example:
>>> Connection('sqs://', transport_options={
...
'polling_interval': 5.0})
The default interval is transport specific, but usually 1.0s (or 5.0s for the Django database transport,
which can also be set using the KOMBU_POLLING_INTERVAL setting).
• Adds convenience function: kombu.common.eventloop().
5.79 2.0.0
release-date 2012-01-15 06:34 P.M GMT
release-by Ask Solem
5.79.1 Important Notes
Python Compatibility
• No longer supports Python 2.4.
Users of Python 2.4 can still use the 1.x series.
The 1.x series has entered bugfix-only maintenance mode, and will stay that way as long as there is
demand, and a willingness to maintain it.
5.78. 2.1.0
67
Kombu Documentation, Release 4.0.0a1
New Transports
• django-kombu is now part of Kombu core.
The Django message transport uses the Django ORM to store messages.
It uses polling, with a default polling interval of 5 seconds. The polling interval can be increased or
decreased by configuring the KOMBU_POLLING_INTERVAL Django setting, which is the polling
interval in seconds as an int or a float. Note that shorter polling intervals can cause extreme strain on
the database: if responsiveness is needed you shall consider switching to a non-polling transport.
To use it you must use transport alias "django", or as an URL:
django://
and then add kombu.transport.django to INSTALLED_APPS, and run manage.py
syncdb to create the necessary database tables.
Upgrading
If you have previously used django-kombu, then the entry in INSTALLED_APPS must be
changed from djkombu to kombu.transport.django:
INSTALLED_APPS = (...,
'kombu.transport.django')
If you have previously used django-kombu, then there is no need to recreate the tables, as the old
tables will be fully compatible with the new version.
• kombu-sqlalchemy is now part of Kombu core.
This change requires no code changes given that the sqlalchemy transport alias is used.
5.79.2 News
• kombu.mixins.ConsumerMixin is a mixin class that lets you easily write consumer programs and
threads.
See Examples and Consumers.
• SQS Transport: Added support for SQS queue prefixes (Issue #84).
The queue prefix can be set using the transport option queue_name_prefix:
BrokerTransport('SQS://', transport_options={
'queue_name_prefix': 'myapp'})
Contributed by Nitzan Miron.
• Producer.publish now supports automatic retry.
Retry is enabled by the reply argument, and retry options set by the retry_policy argument:
exchange = Exchange('foo')
producer.publish(message, exchange=exchange, retry=True,
declare=[exchange], retry_policy={
'interval_start': 1.0})
See ensure() for a list of supported retry policy options.
• Producer.publish now supports a declare keyword argument.
68
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
This is a list of entities (Exchange, or Queue) that should be declared before the message is
published.
5.79.3 Fixes
• Redis transport: Timeout was multiplied by 1000 seconds when using select for event I/O (Issue #86).
5.80 1.5.1
release-date 2011-11-30 01:00 P.M GMT
release-by Ask Solem
• Fixes issue with kombu.compat introduced in 1.5.0 (Issue #83).
• Adds the ability to disable content_types in the serializer registry.
Any message with a content type that is disabled will be refused. One example would be to disable
the Pickle serializer:
>>> from kombu.serialization import registry
# by name
>>> registry.disable('pickle')
# or by mime-type.
>>> registry.disable('application/x-python-serialize')
5.81 1.5.0
release-date 2011-11-27 06:00 P.M GMT
release-by Ask Solem
• kombu.pools: Fixed a bug resulting in resources not being properly released.
This was caused by the use of __hash__ to distinguish them.
• Virtual transports: Dead-letter queue is now disabled by default.
The dead-letter queue was enabled by default to help application authors, but now that Kombu is
stable it should be removed. There are after all many cases where messages should just be dropped
when there are no queues to buffer them, and keeping them without supporting automatic cleanup is
rather considered a resource leak than a feature.
If wanted the dead-letter queue can still be enabled, by using the deadletter_queue transport
option:
>>> x = Connection('redis://',
...
transport_options={'deadletter_queue': 'ae.undeliver'})
In addition, an UndeliverableWarning is now emitted when the dead-letter queue is enabled
and a message ends up there.
Contributed by Ionel Maries Cristian.
• MongoDB transport now supports Replicasets (Issue #81).
Contributed by Ivan Metzlar.
5.80. 1.5.1
69
Kombu Documentation, Release 4.0.0a1
• The Connection.ensure methods now accepts a max_retries value of 0.
A value of 0 now means do not retry, which is distinct from None which means retry indefinitely.
Contributed by Dan McGee.
• SQS Transport: Now has a lowercase sqs alias, so that it can be used with broker URLs (Issue #82).
Fix contributed by Hong Minhee
• SQS Transport: Fixes KeyError on message acknowledgements (Issue #73).
The SQS transport now uses UUID’s for delivery tags, rather than a counter.
Fix contributed by Brian Bernstein.
• SQS Transport: Unicode related fixes (Issue #82).
Fix contributed by Hong Minhee.
• Redis version check could crash because of improper handling of types (Issue #63).
• Fixed error with Resource.force_close_all when resources were not yet properly initialized (Issue #78).
5.82 1.4.3
release-date 2011-10-27 10:00 P.M BST
release-by Ask Solem
• Fixes bug in ProducerPool where too many resources would be acquired.
5.83 1.4.2
release-date 2011-10-26 05:00 P.M BST
release-by Ask Solem
• Eventio: Polling should ignore errno.EINTR
• SQS: str.encode did only start accepting kwargs after Py2.7.
• simple_task_queue example didn’t run correctly (Issue #72).
Fix contributed by Stefan Eletzhofer.
• Empty messages would not raise an exception not able to be handled by on_decode_error (Issue #72)
Fix contributed by Christophe Chauvet.
• CouchDB: Properly authenticate if user/password set (Issue #70)
Fix contributed by Rafael Duran Castaneda
• Connection.Consumer had the wrong signature.
Fix contributed by Pavel Skvazh
70
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
5.84 1.4.1
release-date 2011-09-26 04:00 P.M BST
release-by Ask Solem
• 1.4.0 broke the producer pool, resulting in new connections being established for every acquire.
5.85 1.4.0
release-date 2011-09-22 05:00 P.M BST
release-by Ask Solem
• Adds module kombu.mixins.
This module contains a ConsumerMixin class that can be used to easily implement a message
consumer thread that consumes messages from one or more kombu.Consumer instances.
• New example: Task Queue Example
Using the ConsumerMixin, default channels and the global connection pool to demonstrate new
Kombu features.
• MongoDB transport did not work with MongoDB >= 2.0 (Issue #66)
Fix contributed by James Turk.
• Redis-py version check did not account for beta identifiers in version string.
Fix contributed by David Ziegler.
• Producer and Consumer now accepts a connection instance as the first argument.
The connections default channel will then be used.
In addition shortcut methods has been added to Connection:
>>> connection.Producer(exchange)
>>> connection.Consumer(queues=..., callbacks=...)
• Connection has aquired a connected attribute that can be used to check if the connection instance has established a connection.
• ConnectionPool.acquire_channel now returns the connections default channel rather than establising
a new channel that must be manually handled.
• Added kombu.common.maybe_declare
maybe_declare(entity) declares an entity if it has not previously been declared in the same
process.
• kombu.compat.entry_to_queue() has been moved to kombu.common
• New module kombu.clocks now contains an implementation of Lamports logical clock.
5.86 1.3.5
release-date 2011-09-16 06:00 P.M BST
release-by Ask Solem
5.84. 1.4.1
71
Kombu Documentation, Release 4.0.0a1
• Python 3: AMQP_PROTOCOL_HEADER must be bytes, not str.
5.87 1.3.4
release-date 2011-09-16 06:00 P.M BST
release-by Ask Solem
• Fixes syntax error in pools.reset
5.88 1.3.3
release-date 2011-09-15 02:00 P.M BST
release-by Ask Solem
• pools.reset did not support after forker arguments.
5.89 1.3.2
release-date 2011-09-10 01:00 P.M BST
release-by Mher Movsisyan
• Broke Python 2.5 compatibility by importing parse_qsl from urlparse
• Connection.default_channel is now closed when connection is revived after connection failures.
• Pika: Channel now supports the connection.client attribute as required by the simple interface.
• pools.set_limit now raises an exception if the limit is lower than the previous limit.
• pools.set_limit no longer resets the pools.
5.90 1.3.1
release-date 2011-10-07 03:00 P.M BST
release-by Ask Solem
• Last release broke after fork for pool reinitialization.
• Producer/Consumer now has a connection attribute, giving access to the Connection of the instance.
• Pika:
Channels now have access
channel.connection.client.
to
the
underlying
Connection
instance
using
This was previously required by the Simple classes and is now also required by Consumer and
Producer.
• Connection.default_channel is now closed at object revival.
• Adds kombu.clocks.LamportClock.
• compat.entry_to_queue has been moved to new module kombu.common.
72
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
5.91 1.3.0
release-date 2011-10-05 01:00 P.M BST
release-by Ask Solem
• Broker connection info can be now be specified using URLs
The broker hostname can now be given as an URL instead, of the format:
transport://user:password@hostname:port/virtual_host
for example the default broker is expressed as:
>>> Connection('amqp://guest:guest@localhost:5672//')
Transport defaults to amqp, and is not required. user, password, port and virtual_host is also not
mandatory and will default to the corresponding transports default.
Note: Note that the path component (virtual_host) always starts with a forward-slash. This is
necessary to distinguish between the virtual host ‘’ (empty) and ‘/’, which are both acceptable virtual
host names.
A virtual host of ‘/’ becomes:
amqp://guest:guest@localhost:5672//
and a virtual host of ‘’ (empty) becomes:
amqp://guest:guest@localhost:5672/
So the leading slash in the path component is always required.
• Now comes with default global connection and producer pools.
The acquire a connection using the connection parameters from a Connection:
>>> from kombu import Connection, connections
>>> connection = Connection('amqp://guest:guest@localhost//')
>>> with connections[connection].acquire(block=True):
...
# do something with connection
To acquire a producer using the connection parameters from a Connection:
>>> from kombu import Connection, producers
>>> connection = Connection('amqp://guest:guest@localhost//')
>>> with producers[connection].acquire(block=True):
...
producer.publish({'hello': 'world'}, exchange='hello')
Acquiring a producer will in turn also acquire a connection from the associated pool in
connections, so you the number of producers is bound the same limit as number of connections.
The default limit of 100 connections per connection instance can be changed by doing:
>>> from kombu import pools
>>> pools.set_limit(10)
The pool can also be forcefully closed by doing:
5.91. 1.3.0
73
Kombu Documentation, Release 4.0.0a1
>>> from kombu import pools
>>> pool.reset()
• SQS Transport: Persistence using SimpleDB is now disabled by default, after reports of unstable SimpleDB
connections leading to errors.
• Producer can now be used as a context manager.
• Producer.__exit__ now properly calls release instead of close.
The previous behavior would
kombu.pools.ProducerPool
lead
to
a
memory
leak
when
using
the
• Now silences all exceptions from import ctypes to match behaviour of the standard Python uuid module, and
avoid passing on MemoryError exceptions on SELinux-enabled systems (Issue #52 + Issue #53)
• amqp is now an alias to the amqplib transport.
• kombu.syn.detect_environment now returns ‘default’, ‘eventlet’, or ‘gevent’ depending on what monkey patches have been installed.
• Serialization registry has new attribute type_to_name so it is possible to lookup serializater name by content
type.
• Exchange argument to Producer.publish can now be an Exchange instance.
• compat.Publisher now supports the channel keyword argument.
• Acking a message on some transports could lead to KeyError being raised (Issue #57).
• Connection pool: Connections are no long instantiated when the pool is created, but instantiated as needed
instead.
• Tests now pass on PyPy.
• Connection.as_uri now includes the password if the keyword argument include_password is set.
• Virtual transports now comes with a default default_connection_params attribute.
5.92 1.2.1
release-date 2011-07-29 12:52 P.M BST
release-by Ask Solem
• Now depends on amqplib >= 1.0.0.
• Redis: Now automatically deletes auto_delete queues at basic_cancel.
• serialization.unregister added so it is possible to remove unwanted seralizers.
• Fixes MemoryError while importing ctypes on SELinux (Issue #52).
• Connection.autoretry is a version of ensure that works with arbitrary functions (i.e. it does not need
an associated object that implements the revive method.
Example usage:
channel = connection.channel()
try:
ret, channel = connection.autoretry(send_messages, channel=channel)
finally:
channel.close()
74
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
• ConnectionPool.acquire no longer force establishes the connection.
The connection will be established as needed.
• Connection.ensure now supports an on_revive callback that is applied whenever the connection is
re-established.
• Consumer.consuming_from(queue) returns True if the Consumer is consuming from queue.
• Consumer.cancel_by_queue did not remove the queue from queues.
• compat.ConsumerSet.add_queue_from_dict
auto_declare set.
now
automatically
declared
the
queue
if
5.93 1.2.0
release-date 2011-07-15 12:00 P.M BST
release-by Ask Solem
• Virtual: Fixes cyclic reference in Channel.close (Issue #49).
• Producer.publish: Can now set additional properties using keyword arguments (Issue #48).
• Adds Queue.no_ack option to control the no_ack option for individual queues.
• Recent versions broke pylibrabbitmq support.
• SimpleQueue and SimpleBuffer can now be used as contexts.
• Test requirements specifies PyYAML==3.09 as 3.10 dropped Python 2.4 support
• Now properly reports default values in Connection.info/.as_uri
5.94 1.1.6
release-date 2011-06-13 04:00 P.M BST
release-by Ask Solem
• Redis: Fixes issue introduced in 1.1.4, where a redis connection failure could leave consumer hanging forever.
• SQS: Now supports fanout messaging by using SimpleDB to store routing tables.
This can be disabled by setting the supports_fanout transport option:
>>> Connection(transport='SQS',
...
transport_options={'supports_fanout': False})
• SQS: Now properly deletes a message when a message is acked.
• SQS: Can now set the Amazon AWS region, by using the region transport option.
• amqplib: Now uses localhost as default hostname instead of raising an error.
5.93. 1.2.0
75
Kombu Documentation, Release 4.0.0a1
5.95 1.1.5
release-date 2011-06-07 06:00 P.M BST
release-by Ask Solem
• Fixes compatibility with redis-py 2.4.4.
5.96 1.1.4
release-date 2011-06-07 04:00 P.M BST
release-by Ask Solem
• Redis transport: Now requires redis-py version 2.4.4 or later.
• New Amazon SQS transport added.
Usage:
>>> conn = Connection(transport='SQS',
...
userid=aws_access_key_id,
...
password=aws_secret_access_key)
The environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are also
supported.
• librabbitmq transport: Fixes default credentials support.
• amqplib transport: Now supports login_method for SSL auth.
Connection now supports the login_method keyword argument.
Default login_method is AMQPLAIN.
5.97 1.1.3
release-date 2011-04-21 04:00 P.M CEST
release-by Ask Solem
• Redis: Consuming from multiple connections now works with Eventlet.
• Redis: Can now perform channel operations while the channel is in BRPOP/LISTEN mode (Issue #35).
Also the async BRPOP now times out after 1 second, this means that canceling consuming from a
queue/starting consuming from additional queues has a latency of up to one second (BRPOP does
not support subsecond timeouts).
• Virtual: Allow channel objects to be closed multiple times without error.
• amqplib: AttributeError has been added to the list of known connection related errors
(Connection.connection_errors).
• amqplib: Now converts SSLError timeout errors to socket.timeout (http://bugs.python.org/issue10272)
• Ensures cyclic references are destroyed when the connection is closed.
76
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
5.98 1.1.2
release-date 2011-04-06 04:00 P.M CEST
release-by Ask Solem
• Redis: Fixes serious issue where messages could be lost.
The issue could happen if the message exceeded a certain number of kilobytes in size.
It is recommended that all users of the Redis transport should upgrade to this version, even if not
currently experiencing any issues.
5.99 1.1.1
release-date 2011-04-05 03:51 P.M CEST
release-by Ask Solem
• 1.1.0 started using Queue.LifoQueue which is only available in Python 2.6+ (Issue #33). We now ship with
our own LifoQueue.
5.100 1.1.0
release-date 2011-04-05 01:05 P.M CEST
release-by Ask Solem
5.100.1 Important Notes
• Virtual transports: Message body is now base64 encoded by default (Issue #27).
This should solve problems sending binary data with virtual transports.
Message compatibility is handled by adding a body_encoding property, so messages sent by
older versions is compatible with this release. However – If you are accessing the messages directly
not using Kombu, then you have to respect the body_encoding property.
If you need to disable base64 encoding then you can do so via the transport options:
Connection(transport='...',
transport_options={'body_encoding': None})
For transport authors:
You don’t have to change anything in your custom transports, as this is handled automatically by the base class.
If you want to use a different encoder you can do so by adding a key to Channel.codecs.
Default encoding is specified by the Channel.body_encoding attribute.
A new codec must provide two methods: encode(data) and decode(data).
• ConnectionPool/ChannelPool/Resource: Setting limit=None (or 0) now disables pool semantics, and will
establish and close the resource whenever acquired or released.
• ConnectionPool/ChannelPool/Resource: Is now using a LIFO queue instead of the previous FIFO behavior.
5.98. 1.1.2
77
Kombu Documentation, Release 4.0.0a1
This means that the last resource released will be the one acquired next. I.e. if only a single thread is
using the pool this means only a single connection will ever be used.
• Connection: Cloned connections did not inherit transport_options (__copy__).
• contrib/requirements is now located in the top directory of the distribution.
• MongoDB: Now supports authentication using the userid and password arguments to Connection (Issue
#30).
• Connection: Default autentication credentials are now delegated to the individual transports.
This means that the userid and password arguments to Connection is no longer guest/guest by
default.
The amqplib and pika transports will still have the default credentials.
• Consumer.__exit__() did not have the correct signature (Issue #32).
• Channel objects now have a channel_id attribute.
• MongoDB: Version sniffing broke with development versions of mongod (Issue #29).
• New environment variable KOMBU_LOG_CONNECTION will now emit debug log messages for connection
related actions.
KOMBU_LOG_DEBUG will also enable KOMBU_LOG_CONNECTION.
5.101 1.0.7
release-date 2011-03-28 05:45 P.M CEST
release-by Ask Solem
• Now depends on anyjson 0.3.1
cjson is no longer a recommended json implementation, and anyjson will now emit a deprecation
warning if used.
• Please note that the Pika backend only works with version 0.5.2.
The latest version (0.9.x) drastically changed API, and it is not compatible yet.
• on_decode_error is now called for exceptions in message_to_python (Issue #24).
• Redis: did not respect QoS settings.
• Redis: Creating a connection now ensures the connection is established.
This means Connection.ensure_connection works properly with Redis.
• consumer_tag argument to Queue.consume can’t be None (Issue #21).
A None value is now automatically converted to empty string. An empty string will make the server
generate a unique tag.
• Connection now supports a transport_options argument.
This can be used to pass additional arguments to transports.
• Pika: drain_events raised socket.timeout even if no timeout set (Issue #8).
78
Chapter 5. Change history
Kombu Documentation, Release 4.0.0a1
5.102 1.0.6
release-date 2011-03-22 04:00 P.M CET
release-by Ask Solem
• The delivery_mode aliases (persistent/transient) were not automatically converted to integer, and would
cause a crash if using the amqplib transport.
• Redis: The redis-py InvalidData exception suddenly changed name to DataError.
• The KOMBU_LOG_DEBUG environment variable can now be set to log all channel method calls.
Support for the following environment variables have been added:
– KOMBU_LOG_CHANNEL will wrap channels in an object that logs every method call.
– KOMBU_LOG_DEBUG both enables channel logging and configures the root logger to emit messages to standard error.
Example Usage:
$ KOMBU_LOG_DEBUG=1 python
>>> from kombu import Connection
>>> conn = Connection()
>>> channel = conn.channel()
Start from server, version: 8.0, properties:
{u'product': 'RabbitMQ',.............. }
Open OK! known_hosts []
using channel_id: 1
Channel open
>>> channel.queue_declare('myq', passive=True)
[Kombu channel:1] queue_declare('myq', passive=True)
(u'myq', 0, 1)
5.103 1.0.5
release-date 2011-03-17 04:00 P.M CET
release-by Ask Solem
• Fixed memory leak when creating virtual channels. All virtual transports affected (redis, mongodb, memory,
django, sqlalchemy, couchdb, beanstalk).
• Virtual Transports: Fixed potential race condition when acking messages.
If you have been affected by this, the error would show itself as an exception raised by the OrderedDict implementation. (object no longer exists).
• MongoDB transport requires the findandmodify command only available in MongoDB 1.3+, so now raises
an exception if connected to an incompatible server version.
• Virtual Transports: basic.cancel should not try to remove unknown consumer tag.
5.104 1.0.4
release-date 2011-02-28 04:00 P.M CET
5.102. 1.0.6
79
Kombu Documentation, Release 4.0.0a1
release-by Ask Solem
• Added Transport.polling_interval
Used by django-kombu to increase the time to sleep between SELECTs when there are no messages
in the queue.
Users of django-kombu should upgrade to django-kombu v0.9.2.
5.105 1.0.3
release-date 2011-02-12 04:00 P.M CET
release-by Ask Solem
• ConnectionPool: Re-connect if amqplib connection closed
• Adds Queue.as_dict + Exchange.as_dict.
• Copyright headers updated to include 2011.
5.106 1.0.2
release-date 2011-01-31 10:45 P.M CET
release-by Ask Solem
• amqplib: Message properties were not set properly.
• Ghettoq backend names are now automatically translated to the new names.
5.107 1.0.1
release-date 2011-01-28 12:00 P.M CET
release-by Ask Solem
• Redis: Now works with Linux (epoll)
5.108 1.0.0
release-date 2011-01-27 12:00 P.M CET
release-by Ask Solem
• Initial release
5.109 0.1.0
release-date 2010-07-22 04:20 P.M CET
release-by Ask Solem
• Initial fork of carrot
80
Chapter 5. Change history
CHAPTER 6
Indices and tables
• genindex
• modindex
• search
81
Kombu Documentation, Release 4.0.0a1
82
Chapter 6. Indices and tables
Python Module Index
k
kombu, 27
kombu.exceptions, 28
kombu.syn, 29
83
Kombu Documentation, Release 4.0.0a1
84
Python Module Index
Index
A
T
AWS_ACCESS_KEY_ID, 76
AWS_SECRET_ACCESS_KEY, 76
TimeoutError (in module kombu.exceptions), 28
C
U
URL, 62
ChannelLimitExceeded, 28
ConnectionLimitExceeded, 28
V
D
VHOST, 62
detect_environment() (in module kombu.syn), 29
E
environment variable
AWS_ACCESS_KEY_ID, 76
AWS_SECRET_ACCESS_KEY, 76
KOMBU_LOG_CHANNEL, 79
KOMBU_LOG_CONNECTION, 78
KOMBU_LOG_DEBUG, 78, 79
PICKLE_PROTOCOL, 22, 57
URL, 62
VHOST, 62
K
kombu (module), 27
kombu.exceptions (module), 28
kombu.syn (module), 29
KOMBU_LOG_CHANNEL, 79
KOMBU_LOG_CONNECTION, 78
KOMBU_LOG_DEBUG, 78, 79
L
LimitExceeded, 28
M
MessageStateError, 28
N
NotBoundError, 28
P
PICKLE_PROTOCOL, 22, 57
85
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising