| 32 | |
| 33 | |
| 34 | class QueueConsumer(ConsumerMixin): |
| 35 | def __init__(self, connection, queue): |
| 36 | self.connection = connection |
| 37 | self.queue = queue |
| 38 | |
| 39 | def get_consumers(self, Consumer, channel): |
| 40 | return [ |
| 41 | Consumer( |
| 42 | queues=[self.queue], accept=["pickle"], callbacks=[self.process_task] |
| 43 | ) |
| 44 | ] |
| 45 | |
| 46 | def process_task(self, body, message): |
| 47 | print("===================================================") |
| 48 | print("Received message") |
| 49 | print("message.properties:") |
| 50 | pprint(message.properties) |
| 51 | print("message.delivery_info:") |
| 52 | pprint(message.delivery_info) |
| 53 | print("body:") |
| 54 | pprint(body) |
| 55 | print("===================================================") |
| 56 | |
| 57 | message.ack() |
| 58 | |
| 59 | |
| 60 | def main(queue, exchange, routing_key="#"): |