Class AMSChannel¶
Defined in File rmq.py
Class Documentation¶
- class AMSChannel¶
A wrapper around Pika RabbitMQ channel
Public Functions
- __init__(self, connection, q_name, Optional[Callable] callback=None, Optional[logging.Logger] logger=None)¶
- __enter__(self)¶
- __exit__(self, exc_type, exc_val, exc_tb)¶
- default_callback(self, method, properties, body)¶
Simple callback that return the message received
- open(self)¶
- close(self)¶
- receive(self, int n_msg=None, int timeout=None, accum_msg=list())¶
Consume a message on the queue and post processing by calling the callback. @param n_msg The number of messages to receive. - if n_msg is None, this call will block for ever and will process all messages that arrives - if n_msg = 1 for example, this function will block until one message has been processed. @param timeout If None, timout infinite, otherwise timeout in seconds @return a list containing all received messages
- send(self, str text, str exchange="")¶
Send a message @param text The text to send @param exchange Exchange to use
- get_messages(self)¶
- purge(self)¶
Removes all the messages from the queue.