amqp


Nameamqp JSON
Version 5.2.0 PyPI version JSON
download
home_pagehttp://github.com/celery/py-amqp
SummaryLow-level AMQP client for Python (fork of amqplib).
upload_time2023-11-06 04:54:20
maintainerAsif Saif Uddin, Matus Valo
docs_urlNone
authorBarry Pederson
requires_python>=3.6
licenseBSD
keywords amqp rabbitmq cloudamqp messaging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            =====================================================================
 Python AMQP 0.9.1 client library
=====================================================================

|build-status| |coverage| |license| |wheel| |pyversion| |pyimp|

:Version: 5.2.0
:Web: https://amqp.readthedocs.io/
:Download: https://pypi.org/project/amqp/
:Source: http://github.com/celery/py-amqp/
:Keywords: amqp, rabbitmq

About
=====

This is a fork of amqplib_ which was originally written by Barry Pederson.
It is maintained by the Celery_ project, and used by `kombu`_ as a pure python
alternative when `librabbitmq`_ is not available.

This library should be API compatible with `librabbitmq`_.

.. _amqplib: https://pypi.org/project/amqplib/
.. _Celery: http://celeryproject.org/
.. _kombu: https://kombu.readthedocs.io/
.. _librabbitmq: https://pypi.org/project/librabbitmq/

Differences from `amqplib`_
===========================

- Supports draining events from multiple channels (``Connection.drain_events``)
- Support for timeouts
- Channels are restored after channel error, instead of having to close the
  connection.
- Support for heartbeats

    - ``Connection.heartbeat_tick(rate=2)`` must called at regular intervals
      (half of the heartbeat value if rate is 2).
    - Or some other scheme by using ``Connection.send_heartbeat``.
- Supports RabbitMQ extensions:
    - Consumer Cancel Notifications
        - by default a cancel results in ``ChannelError`` being raised
        - but not if a ``on_cancel`` callback is passed to ``basic_consume``.
    - Publisher confirms
        - ``Channel.confirm_select()`` enables publisher confirms.
        - ``Channel.events['basic_ack'].append(my_callback)`` adds a callback
          to be called when a message is confirmed. This callback is then
          called with the signature ``(delivery_tag, multiple)``.
    - Exchange-to-exchange bindings: ``exchange_bind`` / ``exchange_unbind``.
        - ``Channel.confirm_select()`` enables publisher confirms.
        - ``Channel.events['basic_ack'].append(my_callback)`` adds a callback
          to be called when a message is confirmed. This callback is then
          called with the signature ``(delivery_tag, multiple)``.
    - Authentication Failure Notifications
        Instead of just closing the connection abruptly on invalid
        credentials, py-amqp will raise an ``AccessRefused`` error
        when connected to rabbitmq-server 3.2.0 or greater.
- Support for ``basic_return``
- Uses AMQP 0-9-1 instead of 0-8.
    - ``Channel.access_request`` and ``ticket`` arguments to methods
      **removed**.
    - Supports the ``arguments`` argument to ``basic_consume``.
    - ``internal`` argument to ``exchange_declare`` removed.
    - ``auto_delete`` argument to ``exchange_declare`` deprecated
    - ``insist`` argument to ``Connection`` removed.
    - ``Channel.alerts`` has been removed.
    - Support for ``Channel.basic_recover_async``.
    - ``Channel.basic_recover`` deprecated.
- Exceptions renamed to have idiomatic names:
    - ``AMQPException`` -> ``AMQPError``
    - ``AMQPConnectionException`` -> ConnectionError``
    - ``AMQPChannelException`` -> ChannelError``
    - ``Connection.known_hosts`` removed.
    - ``Connection`` no longer supports redirects.
    - ``exchange`` argument to ``queue_bind`` can now be empty
      to use the "default exchange".
- Adds ``Connection.is_alive`` that tries to detect
  whether the connection can still be used.
- Adds ``Connection.connection_errors`` and ``.channel_errors``,
  a list of recoverable errors.
- Exposes the underlying socket as ``Connection.sock``.
- Adds ``Channel.no_ack_consumers`` to keep track of consumer tags
  that set the no_ack flag.
- Slightly better at error recovery

Quick overview
==============

Simple producer publishing messages to ``test`` queue using default exchange:

.. code:: python

    import amqp

    with amqp.Connection('broker.example.com') as c:
        ch = c.channel()
        ch.basic_publish(amqp.Message('Hello World'), routing_key='test')

Producer publishing to ``test_exchange`` exchange with publisher confirms enabled and using virtual_host ``test_vhost``:

.. code:: python

    import amqp

    with amqp.Connection(
        'broker.example.com', exchange='test_exchange',
        confirm_publish=True, virtual_host='test_vhost'
    ) as c:
        ch = c.channel()
        ch.basic_publish(amqp.Message('Hello World'), routing_key='test')

Consumer with acknowledgments enabled:

.. code:: python

    import amqp

    with amqp.Connection('broker.example.com') as c:
        ch = c.channel()
        def on_message(message):
            print('Received message (delivery tag: {}): {}'.format(message.delivery_tag, message.body))
            ch.basic_ack(message.delivery_tag)
        ch.basic_consume(queue='test', callback=on_message)
        while True:
            c.drain_events()


Consumer with acknowledgments disabled:

.. code:: python

    import amqp

    with amqp.Connection('broker.example.com') as c:
        ch = c.channel()
        def on_message(message):
            print('Received message (delivery tag: {}): {}'.format(message.delivery_tag, message.body))
        ch.basic_consume(queue='test', callback=on_message, no_ack=True)
        while True:
            c.drain_events()

Speedups
========

This library has **experimental** support of speedups. Speedups are implemented using Cython. To enable speedups, ``CELERY_ENABLE_SPEEDUPS`` environment variable must be set during building/installation.
Currently speedups can be installed:

1. using source package (using ``--no-binary`` switch):

.. code:: shell

    CELERY_ENABLE_SPEEDUPS=true pip install --no-binary :all: amqp


2. building directly source code:

.. code:: shell

    CELERY_ENABLE_SPEEDUPS=true python setup.py install

Further
=======

- Differences between AMQP 0.8 and 0.9.1

    http://www.rabbitmq.com/amqp-0-8-to-0-9-1.html

- AMQP 0.9.1 Quick Reference

    http://www.rabbitmq.com/amqp-0-9-1-quickref.html

- RabbitMQ Extensions

    http://www.rabbitmq.com/extensions.html

- For more information about AMQP, visit

    http://www.amqp.org

- For other Python client libraries see:

    http://www.rabbitmq.com/devtools.html#python-dev

.. |build-status| image:: https://github.com/celery/py-amqp/actions/workflows/ci.yaml/badge.svg
    :alt: Build status
    :target: https://github.com/celery/py-amqp/actions/workflows/ci.yaml

.. |coverage| image:: https://codecov.io/github/celery/py-amqp/coverage.svg?branch=main
    :target: https://codecov.io/github/celery/py-amqp?branch=main

.. |license| image:: https://img.shields.io/pypi/l/amqp.svg
    :alt: BSD License
    :target: https://opensource.org/licenses/BSD-3-Clause

.. |wheel| image:: https://img.shields.io/pypi/wheel/amqp.svg
    :alt: Python AMQP can be installed via wheel
    :target: https://pypi.org/project/amqp/

.. |pyversion| image:: https://img.shields.io/pypi/pyversions/amqp.svg
    :alt: Supported Python versions.
    :target: https://pypi.org/project/amqp/

.. |pyimp| image:: https://img.shields.io/pypi/implementation/amqp.svg
    :alt: Support Python implementations.
    :target: https://pypi.org/project/amqp/

py-amqp as part of the Tidelift Subscription
============================================

The maintainers of py-amqp and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/pypi-amqp?utm_source=pypi-amqp&utm_medium=referral&utm_campaign=readme&utm_term=repo)




            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/celery/py-amqp",
    "name": "amqp",
    "maintainer": "Asif Saif Uddin, Matus Valo",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "amqp rabbitmq cloudamqp messaging",
    "author": "Barry Pederson",
    "author_email": "auvipy@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/32/2c/6eb09fbdeb3c060b37bd33f8873832897a83e7a428afe01aad333fc405ec/amqp-5.2.0.tar.gz",
    "platform": "any",
    "description": "=====================================================================\n Python AMQP 0.9.1 client library\n=====================================================================\n\n|build-status| |coverage| |license| |wheel| |pyversion| |pyimp|\n\n:Version: 5.2.0\n:Web: https://amqp.readthedocs.io/\n:Download: https://pypi.org/project/amqp/\n:Source: http://github.com/celery/py-amqp/\n:Keywords: amqp, rabbitmq\n\nAbout\n=====\n\nThis is a fork of amqplib_ which was originally written by Barry Pederson.\nIt is maintained by the Celery_ project, and used by `kombu`_ as a pure python\nalternative when `librabbitmq`_ is not available.\n\nThis library should be API compatible with `librabbitmq`_.\n\n.. _amqplib: https://pypi.org/project/amqplib/\n.. _Celery: http://celeryproject.org/\n.. _kombu: https://kombu.readthedocs.io/\n.. _librabbitmq: https://pypi.org/project/librabbitmq/\n\nDifferences from `amqplib`_\n===========================\n\n- Supports draining events from multiple channels (``Connection.drain_events``)\n- Support for timeouts\n- Channels are restored after channel error, instead of having to close the\n  connection.\n- Support for heartbeats\n\n    - ``Connection.heartbeat_tick(rate=2)`` must called at regular intervals\n      (half of the heartbeat value if rate is 2).\n    - Or some other scheme by using ``Connection.send_heartbeat``.\n- Supports RabbitMQ extensions:\n    - Consumer Cancel Notifications\n        - by default a cancel results in ``ChannelError`` being raised\n        - but not if a ``on_cancel`` callback is passed to ``basic_consume``.\n    - Publisher confirms\n        - ``Channel.confirm_select()`` enables publisher confirms.\n        - ``Channel.events['basic_ack'].append(my_callback)`` adds a callback\n          to be called when a message is confirmed. This callback is then\n          called with the signature ``(delivery_tag, multiple)``.\n    - Exchange-to-exchange bindings: ``exchange_bind`` / ``exchange_unbind``.\n        - ``Channel.confirm_select()`` enables publisher confirms.\n        - ``Channel.events['basic_ack'].append(my_callback)`` adds a callback\n          to be called when a message is confirmed. This callback is then\n          called with the signature ``(delivery_tag, multiple)``.\n    - Authentication Failure Notifications\n        Instead of just closing the connection abruptly on invalid\n        credentials, py-amqp will raise an ``AccessRefused`` error\n        when connected to rabbitmq-server 3.2.0 or greater.\n- Support for ``basic_return``\n- Uses AMQP 0-9-1 instead of 0-8.\n    - ``Channel.access_request`` and ``ticket`` arguments to methods\n      **removed**.\n    - Supports the ``arguments`` argument to ``basic_consume``.\n    - ``internal`` argument to ``exchange_declare`` removed.\n    - ``auto_delete`` argument to ``exchange_declare`` deprecated\n    - ``insist`` argument to ``Connection`` removed.\n    - ``Channel.alerts`` has been removed.\n    - Support for ``Channel.basic_recover_async``.\n    - ``Channel.basic_recover`` deprecated.\n- Exceptions renamed to have idiomatic names:\n    - ``AMQPException`` -> ``AMQPError``\n    - ``AMQPConnectionException`` -> ConnectionError``\n    - ``AMQPChannelException`` -> ChannelError``\n    - ``Connection.known_hosts`` removed.\n    - ``Connection`` no longer supports redirects.\n    - ``exchange`` argument to ``queue_bind`` can now be empty\n      to use the \"default exchange\".\n- Adds ``Connection.is_alive`` that tries to detect\n  whether the connection can still be used.\n- Adds ``Connection.connection_errors`` and ``.channel_errors``,\n  a list of recoverable errors.\n- Exposes the underlying socket as ``Connection.sock``.\n- Adds ``Channel.no_ack_consumers`` to keep track of consumer tags\n  that set the no_ack flag.\n- Slightly better at error recovery\n\nQuick overview\n==============\n\nSimple producer publishing messages to ``test`` queue using default exchange:\n\n.. code:: python\n\n    import amqp\n\n    with amqp.Connection('broker.example.com') as c:\n        ch = c.channel()\n        ch.basic_publish(amqp.Message('Hello World'), routing_key='test')\n\nProducer publishing to ``test_exchange`` exchange with publisher confirms enabled and using virtual_host ``test_vhost``:\n\n.. code:: python\n\n    import amqp\n\n    with amqp.Connection(\n        'broker.example.com', exchange='test_exchange',\n        confirm_publish=True, virtual_host='test_vhost'\n    ) as c:\n        ch = c.channel()\n        ch.basic_publish(amqp.Message('Hello World'), routing_key='test')\n\nConsumer with acknowledgments enabled:\n\n.. code:: python\n\n    import amqp\n\n    with amqp.Connection('broker.example.com') as c:\n        ch = c.channel()\n        def on_message(message):\n            print('Received message (delivery tag: {}): {}'.format(message.delivery_tag, message.body))\n            ch.basic_ack(message.delivery_tag)\n        ch.basic_consume(queue='test', callback=on_message)\n        while True:\n            c.drain_events()\n\n\nConsumer with acknowledgments disabled:\n\n.. code:: python\n\n    import amqp\n\n    with amqp.Connection('broker.example.com') as c:\n        ch = c.channel()\n        def on_message(message):\n            print('Received message (delivery tag: {}): {}'.format(message.delivery_tag, message.body))\n        ch.basic_consume(queue='test', callback=on_message, no_ack=True)\n        while True:\n            c.drain_events()\n\nSpeedups\n========\n\nThis library has **experimental** support of speedups. Speedups are implemented using Cython. To enable speedups, ``CELERY_ENABLE_SPEEDUPS`` environment variable must be set during building/installation.\nCurrently speedups can be installed:\n\n1. using source package (using ``--no-binary`` switch):\n\n.. code:: shell\n\n    CELERY_ENABLE_SPEEDUPS=true pip install --no-binary :all: amqp\n\n\n2. building directly source code:\n\n.. code:: shell\n\n    CELERY_ENABLE_SPEEDUPS=true python setup.py install\n\nFurther\n=======\n\n- Differences between AMQP 0.8 and 0.9.1\n\n    http://www.rabbitmq.com/amqp-0-8-to-0-9-1.html\n\n- AMQP 0.9.1 Quick Reference\n\n    http://www.rabbitmq.com/amqp-0-9-1-quickref.html\n\n- RabbitMQ Extensions\n\n    http://www.rabbitmq.com/extensions.html\n\n- For more information about AMQP, visit\n\n    http://www.amqp.org\n\n- For other Python client libraries see:\n\n    http://www.rabbitmq.com/devtools.html#python-dev\n\n.. |build-status| image:: https://github.com/celery/py-amqp/actions/workflows/ci.yaml/badge.svg\n    :alt: Build status\n    :target: https://github.com/celery/py-amqp/actions/workflows/ci.yaml\n\n.. |coverage| image:: https://codecov.io/github/celery/py-amqp/coverage.svg?branch=main\n    :target: https://codecov.io/github/celery/py-amqp?branch=main\n\n.. |license| image:: https://img.shields.io/pypi/l/amqp.svg\n    :alt: BSD License\n    :target: https://opensource.org/licenses/BSD-3-Clause\n\n.. |wheel| image:: https://img.shields.io/pypi/wheel/amqp.svg\n    :alt: Python AMQP can be installed via wheel\n    :target: https://pypi.org/project/amqp/\n\n.. |pyversion| image:: https://img.shields.io/pypi/pyversions/amqp.svg\n    :alt: Supported Python versions.\n    :target: https://pypi.org/project/amqp/\n\n.. |pyimp| image:: https://img.shields.io/pypi/implementation/amqp.svg\n    :alt: Support Python implementations.\n    :target: https://pypi.org/project/amqp/\n\npy-amqp as part of the Tidelift Subscription\n============================================\n\nThe maintainers of py-amqp and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/pypi-amqp?utm_source=pypi-amqp&utm_medium=referral&utm_campaign=readme&utm_term=repo)\n\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Low-level AMQP client for Python (fork of amqplib).",
    "version": "5.2.0",
    "project_urls": {
        "Homepage": "http://github.com/celery/py-amqp"
    },
    "split_keywords": [
        "amqp",
        "rabbitmq",
        "cloudamqp",
        "messaging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3f08e5be5d5e0653d9e1d02b1144efa33ff7d2963dfad07049e02c0fa9b2e8d",
                "md5": "832f87e10bf35fdf524dfb28734fd10c",
                "sha256": "827cb12fb0baa892aad844fd95258143bce4027fdac4fccddbc43330fd281637"
            },
            "downloads": -1,
            "filename": "amqp-5.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "832f87e10bf35fdf524dfb28734fd10c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 50917,
            "upload_time": "2023-11-06T04:54:08",
            "upload_time_iso_8601": "2023-11-06T04:54:08.603455Z",
            "url": "https://files.pythonhosted.org/packages/b3/f0/8e5be5d5e0653d9e1d02b1144efa33ff7d2963dfad07049e02c0fa9b2e8d/amqp-5.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "322c6eb09fbdeb3c060b37bd33f8873832897a83e7a428afe01aad333fc405ec",
                "md5": "bd24760edbc5e4bfd58370b5d44c0f7e",
                "sha256": "a1ecff425ad063ad42a486c902807d1482311481c8ad95a72694b2975e75f7fd"
            },
            "downloads": -1,
            "filename": "amqp-5.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bd24760edbc5e4bfd58370b5d44c0f7e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 128754,
            "upload_time": "2023-11-06T04:54:20",
            "upload_time_iso_8601": "2023-11-06T04:54:20.099938Z",
            "url": "https://files.pythonhosted.org/packages/32/2c/6eb09fbdeb3c060b37bd33f8873832897a83e7a428afe01aad333fc405ec/amqp-5.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-06 04:54:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "celery",
    "github_project": "py-amqp",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "amqp"
}
        
Elapsed time: 0.14043s