#!/usr/bin/env python3 # -*- coding: utf-8 -*- import amqp from amqp.basic_message import Message def recv_callback(msg): headers = msg.headers print(headers.get("loggerName") + " " + msg.body.decode('utf-8')) if __name__ == "__main__": with amqp.Connection( host="localhost:5672", userid="admin", password="123456", virtual_host="/", insist=False) as c: channel = c.channel() channel.basic_consume(queue='proxylogtopic', callback=recv_callback, no_ack=True) while True: c.drain_events()