API¶
The public API of Henson-AMQP.
AMQP¶
-
class
henson_amqp.
AMQP
(app=None)[source]¶ An interface to interact with an AMQP broker.
-
consumer
()[source]¶ Return a new AMQP consumer.
Returns: - A new consumer object that can be used to read
- from the AMQP broker and queue specified the Application’s settings.
Return type: Consumer
-
Consumer¶
-
class
henson_amqp.
Consumer
(app)[source]¶ A consumer of an AMQP queue.
Parameters: app (henson.base.Application) – The application for which this consumer consumes. -
read
()[source]¶ Read a single message from the message queue.
If the consumer has not yet begun reading from the AMQP broker, that process is initiated before yielding from the queue.
Returns: The next available message. Return type: Message Raises: aioamqp.exceptions.AioamqpException
– The exception raised on connection close.
-
retry
(app, message)[source]¶ Requeue a message to be processed again.
This coroutine is meant for use with the
henson.contrib.retry.Retry
extension.Parameters: - app (henson.base.Application) – The application processing the message.
- message (dict) – A copy of the message read from the AMQP server.
Note
This function assumes that messages are JSON serializeable. If they are not, a custom function may be used in its place.
-