Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Implementation of rabbitmq with asynqp

Project description

rabbitmq_asynqp

Python package for using rabbitmq using asynqp

Usage:

  • Both producer and consumer:

    rabbitmq_asynqp provides you ability to use rabbitmq messaging asynchronous non-blocking way by the use of asynqp and asyncio with just few lines of code. Typical usage will be like this:

          from rabbitmq_asynqp.messaging import Messaging
    
          rabbitmq_config = dict(host="localhost", port=5672, username="guest", password="guest")
          queue_config = dict(
                  exchange="sample_exchange",
                  queues=["sample_queue1"],
                  routing_key="sample.routing_key",
                  exchange_type="direct",
                  error_messaging=dict(
                      exchange="error_exchange",
                      queues=["error_queue"],
                      routing_key="error.key",
                      exchange_type="direct",
                  )
              )
    
          queue_settings = {'reconnect_backoff_secs': 1, 'connection_check_polling_secs': 5} # Not compulsory
    
          def consumer_func(message: dict):
              # define your consumer func
              pass
    
          messaging = Messaging(rabbitmq_config: dict, queue_config: dict, consumer_func)
    

    use this messaging object globally for sending message like this:

          messaging.send_message(message) # To send single message
          messaging.send_messages(messages) # To send multiple bulk messages
    
  • Only Consumer:

    To run only consumer use a separate thread or process and do following:

          from rabbitmq_asynqp.messaging import Consumer
    
          rabbitmq_config = dict(host="localhost", port=5672, username="guest", password="guest")
          queue = "queue_name"
          queue_settings = {'reconnect_backoff_secs': 1, 'connection_check_polling_secs': 5} # Not compulsory
    
          def consumer_func(message:dict):
              # define your consumer func
              pass
    
          consumer = Consumer(rabbitmq_config, queue, consumer_func, queue_settings)
          consumer()
    
  • Only Producer:

    To run producer only for message production:

          from rabbitmq_asynqp.messaging import Producer
    
          rabbitmq_config = dict(host="localhost", port=5672, username="guest", password="guest")
          queue_config = dict(
                  exchange="sample_exchange",
                  queues=["sample_queue1"],
                  routing_key="sample.routing_key",
                  exchange_type="direct",
                  error_messaging=dict(
                      exchange="error_exchange",
                      queues=["error_queue"],
                      routing_key="error.key",
                      exchange_type="direct",
                  )
              )
    
          producer = Producer(rabbitmq_config, queue_config)
          producer.send_msg(message)
    

Message sent must be dict.

For any queries, mail to akshay2agarwal@gmail.com

Project details


Download files

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

Files for rabbitmq-asynqp, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size rabbitmq_asynqp-0.1.1-py3-none-any.whl (11.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size rabbitmq_asynqp-0.1.1.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page