On Thu, Feb 14, 2013 at 5:44 PM, Alan Conway <acon...@redhat.com> wrote:

> I'm looking (in python first) to encode messages that contain all the
> different AMQP types. So far I was using the Data class to construct
> different AMQP data fragments. However I'd like to move towards using a
> map message as it's more widely decodable. So my question: how do I
> create a map message that contains specific AMQP types?  I.e. I want to
> differentiate between shorts, ints and longs, between symbols and
> strings etc. Just setting message.body = Data(...) does not work,
> message wants to have a python dict or list as a body.

For the python binding I've defined the following classes to cover types
that python doesn't natively support:

class UnmappedType
class ulong(long)
class timestamp(long)
class symbol(unicode)
class char(unicode)
class Described(object)
class Array(object)

So you should just be able to do:

message.body = {u"ulong": ulong(1234), u"char": char(u"\u1234"),
u"timestamp": timestamp(12345678), u"described-string":
Described(symbol("url-descriptor"), u"http://blah";), u"array":
Array(UNDESCRIBED, Data.INT, 1, 2, 3, 4), u"described-array":
Array(symbol("url-descriptor"), u"http://blah1";, u"http://blah2";)}


Reply via email to