AMQPAdapter

Example:

from message_queue import AMQPAdapter

adapter = AMQPAdapter(host='0.0.0.0')

AMQP 0.9.1 Adapter to connect to RabbitMQ using pika library.

Publish and subscribe to queues and exchanges in RabbitMQ

class message_queue.adapters.amqp_adapter.AMQPAdapter(host='localhost', port=5672, user='guest', password='guest', vhost='/')

Bases: message_queue.adapters.base_adapter.BaseAdapter

__init__(host='localhost', port=5672, user='guest', password='guest', vhost='/')

Create the connection credentials and parameters then connect.

Parameters:
  • host (string) – Server host
  • port (int) – Server port
  • user (string) – Server server user
  • password (string) – Server server password
  • vhost (string) – Server virutal host
close()

Close connection and channel.

configurate_queue(**kwargs)

Configurate the queue.

Parameters:
  • prefetch_count (int) – Specifies a prefetch window in terms of whole messages
  • queue (string) – Queue name to connect
  • passive (bool) – Only check to see if the queue exists
  • dureble (bool) – Survive reboots of the broker
  • exclusive (bool) – Only allow access by the current connection
  • auto_delete (bool) – Delete after consumer cancels or disconnects
  • arguments (bool) – Custom key/value arguments for the queue
connect()

Connect to AMQP server usgin BlockingConnection.

consume(worker)

Consume message from the queue.

Parameters:worker (function) – Method that consume the message
consume_callback(worker)

Decorate worker to exectue on consume callback.

Parameters:worker (function) – Worker to execture in the consume callback
format_message(message)

Format message to AMQP format.

Parameters:message (dict) – Message to format
send(message)

Publish a message in the queue.

Parameters:message (Message) – Message to publish in the channel