Skip to main content

Python interface for simple usage of AMQP middleware applications.

Project description

PyAMQP

Python interface for simple usage of AMQP middleware applications.

This interface is made to ease the process of using AMQP software.

The applications supported so far:

  • RabbitMQ: This is a popular open-source message-broker that implemented the Advanced Message Queuing Protocol (AMQP) written in the Erlang programming language

How to get it

pip install pyamqp

Dependencies

Pika: 0.13 or higher

pytest: 4.0.2 or higher

Usage example

RabbitMQ - Receiver

from pyamqp.rabbit.receiver import Receiver

# Initializing and creating the connection with the Rabbit server
receiver_instance = Receiver(host='18.222.222.222',
                             port=5672,
                             user='guest',
                             password='1245554221')

# Declares the queue with the specified parameters, 
# binds it to an exchange using the routing_keys list.
receiver_instance.connect_queue(queue_name='test',
                                exchange='test_exchange',
                                routing_keys=['A', 'B'],
                                is_durable=True,
                                auto_delete=False)
# callback function
# Not necesary if inheritance is used
def get_message(message, details):
    some_value = message.get('some_key', None)
    print(some_value)

receiver_instance.consume(callback_function=get_message,
                          no_ack=True,
                          consumer_tag='AAAAKKK_2232')

Rabbit-Dispatcher

from pyamqp.rabbit.dispatcher import Dispatcher

dispatcher_instance = Dispatcher(host='18.222.222.222',
                                 port=5672,
                                 user='guest',
                                 password='1245554221')

# Declaring exchanges that are going to be used for sending messages
# exchanges parameter can be an string or a list of strings                               
dispatcher_instance.connect_exchanges(exchanges=['test_exch', 'test_exch_2],
                                      exchange_type='topic',
                                      auto_delete=True)


# There can be only two types of passed messages, string or dicts.
message_1 = 'Hello'
message_2 = {'Ciao': 'Hola'} 

dispatcher.send_message(message_1, 'THIS.IS.A.KEY', 'test_exch')
dispatcher.send_message(message_2, 'KEY.SOMETHING', 'test_exch_2')

Current limitations

  • There's only support for BlockingConnection adapter since this is the main adapter used in production.
  • Threaded Receiver class is not thread-safe, will be added using an internal instance of Queue() to address that issue.
  • This packages does not support the inheritance of Receiver and Dispatcher in the same child class.

License

GNU GPLv3

Permissions of this strong copyleft license are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyAMQP-0.0.7.7.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyAMQP-0.0.7.7-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file PyAMQP-0.0.7.7.tar.gz.

File metadata

  • Download URL: PyAMQP-0.0.7.7.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for PyAMQP-0.0.7.7.tar.gz
Algorithm Hash digest
SHA256 f8b0b6c29c4e15faeb98581cc7d7dd7e46476c349e828c37836c1b0a6190f3ce
MD5 241b40a9058761750a0e440d575ede34
BLAKE2b-256 7168ebf95f4e3b7ed5ba2b7a0202b7244c2753f44cc189ea8673f5b8e838c6ce

See more details on using hashes here.

File details

Details for the file PyAMQP-0.0.7.7-py2.py3-none-any.whl.

File metadata

  • Download URL: PyAMQP-0.0.7.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for PyAMQP-0.0.7.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d694c39fdc0c88c60bb444dbca686f4eeaafb2d8c97cc9497541b1840dd494f8
MD5 e1a7f96bbb7f1d92a472809ea2a20b9c
BLAKE2b-256 d05e186b7069c3e018e877897e58a959f8ba8cfc7cd50f6a8ccafec1a79eed57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page