我正在尝试从 python 中的 amqp 代理接收消息。这是我的代码:
#!/usr/bin/python
import sys
import os
import getopt
from qpid.messaging import *
from qpid.log import enable, DEBUG
broker_rcv = "admin/admin@hostname:IP"
address_rcv = "broadcast.QUEUE_NAME.QUEUE_NAME" + "; { node: { type: queue }, assert: never , create: never, mode: " + "browse" + " }"
connection_rcv = Connection(broker_rcv)
connection_rcv.open()
session_rcv = connection_rcv.session()
receiver = session_rcv.receiver(address_rcv)
msg = receiver.fetch(timeout=None)
print msg.content
但是当我尝试打印消息时,我看到它们的编码很奇怪,并且无法更改消息编码。
我做错了什么?