kombu.compat — Kombu v1.3.2 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Kombu v1.3.2 documentation »
- API Reference »

# kombu.compat

Carrot compatible interface for `Publisher` and `Producer`.

See http://packages.python.org/pypi/carrot for documentation.

copyright: | 2009 - 2011 by Ask Solem.
license: | BSD, see LICENSE for more details.

- Publisher
- Consumer
- ConsumerSet

## Publisher

Replace with `kombu.messaging.Producer`.

class `kombu.compat.` `Publisher`(connection, exchange=None, routing_key=None, exchange_type=None, durable=None, auto_delete=None, channel=None, **kwargs)
  `close`()
  `declare`()

    Declare the exchange.

    This is done automatically at instantiation if `auto_declare` is set to `True`.

  `publish`(body, routing_key=None, delivery_mode=None, mandatory=False, immediate=False, priority=0, content_type=None, content_encoding=None, serializer=None, headers=None, compression=None, exchange=None, **properties)

    Publish message to the specified exchange.

    Parameters: | body – Message body. routing_key – Message routing key. delivery_mode – See `delivery_mode`. mandatory – Currently not supported. immediate – Currently not supported. priority – Message priority. A number between 0 and 9. content_type – Content type. Default is autodetect. content_encoding – Content encoding. Default is autodetect. serializer – Serializer to use. Default is autodetect. headers – Mapping of arbitrary headers to pass along with the message body. exchange – Override the exchange. Note that this exchange must have been declared. properties – Additional properties, see the AMQP spec.

  `release`()
  `revive`(channel)
  `send`(*args, **kwargs)

## Consumer

Replace with `kombu.messaging.Consumer`.

class `kombu.compat.` `Consumer`(connection, queue=None, exchange=None, routing_key=None, exchange_type=None, durable=None, exclusive=None, auto_delete=None, **kwargs)
  `add_queue`(queue)
  `cancel`()

    End all active queue consumers.

    This does not affect already delivered messages, but it does mean the server will not send any more messages for this consumer.

  `cancel_by_queue`(queue)

    Cancel consumer by queue name.

  `close`()
  `consume`(no_ack=None)

    Register consumer on server.

  `consuming_from`(queue)
  `declare`()

    Declare queues, exchanges and bindings.

    This is done automatically at instantiation if `auto_declare` is set.

  `discard_all`(filterfunc=None)
  `fetch`(no_ack=None, enable_callbacks=False)
  `flow`(active)

    Enable/disable flow from peer.

    This is a simple flow-control mechanism that a peer can use to avoid overflowing its queues or otherwise finding itself receiving more messages than it can process.

    The peer that receives a request to stop sending content will finish sending the current content (if any), and then wait until flow is reactivated.

  `iterconsume`(limit=None, no_ack=None)
  `iterqueue`(limit=None, infinite=False)
  `process_next`()
  `purge`()

    Purge messages from all queues.

    Warning

    This will delete all ready messages, there is no undo operation available.

  `qos`(prefetch_size=0, prefetch_count=0, apply_global=False)

    Specify quality of service.

    The client can request that messages should be sent in advance so that when the client finishes processing a message, the following message is already held locally, rather than needing to be sent down the channel. Prefetching gives a performance improvement.

    The prefetch window is Ignored if the `no_ack` option is set.

    Parameters: | prefetch_size – Specify the prefetch window in octets. The server will send a message in advance if it is equal to or smaller in size than the available prefetch size (and also falls within other prefetch limits). May be set to zero, meaning “no specific limit”, although other prefetch limits may still apply. prefetch_count – Specify the prefetch window in terms of whole messages. apply_global – Apply new settings globally on all channels. Currently not supported by RabbitMQ.

  `receive`(body, message)

    Method called when a message is received.

    This dispatches to the registered `callbacks`.

    Parameters: | body – The decoded message body. message – The Message instance.
    Raises NotImplementedError:
    | If no consumer callbacks have been registered.

  `recover`(requeue=False)

    Redeliver unacknowledged messages.

    Asks the broker to redeliver all unacknowledged messages on the specified channel.

    Parameters: | requeue – By default the messages will be redelivered to the original recipient. With requeue set to true, the server will attempt to requeue the message, potentially then delivering it to an alternative subscriber.

  `register_callback`(callback)

    Register a new callback to be called when a message is received.

    The signature of the callback needs to accept two arguments: (body, message), which is the decoded message body and the Message instance (a subclass of `Message`.

  `revive`(channel)
  `wait`(limit=None)

## ConsumerSet

Replace with `kombu.messaging.Consumer`.

class `kombu.compat.` `ConsumerSet`(connection, from_dict=None, consumers=None, callbacks=None, **kwargs)
  `add_consumer`(consumer)
  `add_consumer_from_dict`(queue, **options)
  `add_queue`(queue)
  `cancel`()

    End all active queue consumers.

    This does not affect already delivered messages, but it does mean the server will not send any more messages for this consumer.

  `cancel_by_queue`(queue)

    Cancel consumer by queue name.

  `close`()
  `consume`(no_ack=None)

    Register consumer on server.

  `consuming_from`(queue)
  `declare`()

    Declare queues, exchanges and bindings.

    This is done automatically at instantiation if `auto_declare` is set.

  `discard_all`()
  `flow`(active)

    Enable/disable flow from peer.

    This is a simple flow-control mechanism that a peer can use to avoid overflowing its queues or otherwise finding itself receiving more messages than it can process.

    The peer that receives a request to stop sending content will finish sending the current content (if any), and then wait until flow is reactivated.

  `iterconsume`(limit=None, no_ack=False)
  `purge`()

    Purge messages from all queues.

    Warning

    This will delete all ready messages, there is no undo operation available.

  `qos`(prefetch_size=0, prefetch_count=0, apply_global=False)

    Specify quality of service.

    The client can request that messages should be sent in advance so that when the client finishes processing a message, the following message is already held locally, rather than needing to be sent down the channel. Prefetching gives a performance improvement.

    The prefetch window is Ignored if the `no_ack` option is set.

    Parameters: | prefetch_size – Specify the prefetch window in octets. The server will send a message in advance if it is equal to or smaller in size than the available prefetch size (and also falls within other prefetch limits). May be set to zero, meaning “no specific limit”, although other prefetch limits may still apply. prefetch_count – Specify the prefetch window in terms of whole messages. apply_global – Apply new settings globally on all channels. Currently not supported by RabbitMQ.

  `receive`(body, message)

    Method called when a message is received.

    This dispatches to the registered `callbacks`.

    Parameters: | body – The decoded message body. message – The Message instance.
    Raises NotImplementedError:
    | If no consumer callbacks have been registered.

  `recover`(requeue=False)

    Redeliver unacknowledged messages.

    Asks the broker to redeliver all unacknowledged messages on the specified channel.

    Parameters: | requeue – By default the messages will be redelivered to the original recipient. With requeue set to true, the server will attempt to requeue the message, potentially then delivering it to an alternative subscriber.

  `register_callback`(callback)

    Register a new callback to be called when a message is received.

    The signature of the callback needs to accept two arguments: (body, message), which is the decoded message body and the Message instance (a subclass of `Message`.

  `revive`(channel)

### Navigation

- index
- modules |
- next |
- previous |
- Kombu v1.3.2 documentation »
- API Reference »