简体   繁体   中英

python qpid message encoding

I'm trying to receive messages from amqp broker in python. Here is my code:

#!/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

But when I try to print messages I see them in strange encoding and there is no way how to change message encoding.

What I'm doing wrong?

msg.content contains the original message content sent by some producer. You cannot change it. And what is the encoding you metioned above? If you saw that when print msg, just ignore it.

What you are doing wrong is that you are failing to decode the messages. When you receive an encoded message, you have to begin by decoding it.

Are those FIX messages? All the technical specs are here http://fixprotocol.org/specifications/

One Python library is here http://source.kentyde.com/fixlib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM