<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-ZA link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='color:#1F497D'>Hi there,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>I seemed to have solved the
issue....it all had to do with the “content_encoding”....so I replaced this:<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Content = #content{class_id =
60,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> </span><span
style='color:red'>properties = amqp_util:basic_properties(),<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> properties
= Properties,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>
properties_bin = none, <o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>
payload_fragments_rev = [Payload]<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> },<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>With this:<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Properties = #'P_basic'{content_type
= <<"application/octet-stream">>,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> </span><span
style='color:red'>content_encoding = <<"binary">>,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> delivery_mode
= 1,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> priority =
0},<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> Content =
#content{class_id = 60,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> properties
= Properties,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>
properties_bin = none, <o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>
payload_fragments_rev = [Payload]<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> },<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Now my Python consumer in CARROT
is working 100% ;-)<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Chat later<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Lynton<o:p></o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> rabbitmq-discuss-bounces@lists.rabbitmq.com
[mailto:rabbitmq-discuss-bounces@lists.rabbitmq.com] <b>On Behalf Of </b>Lynton
Grice<br>
<b>Sent:</b> 12 July 2009 07:13 PM<br>
<b>To:</b> rabbitmq-discuss@lists.rabbitmq.com<br>
<b>Subject:</b> [rabbitmq-discuss] RabbitMQ Consumer Error<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Hi there,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I wonder if someone can help me on this one. I am building
the following scenario:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='color:red'>Client -> Mochiweb -> RabbitMQ
(via Erlang RabbitMQ Client code) -> <u>Python consumer</u> (using the
Python CARROT AMQP library)<o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I have everything working right until the Python consumer
picks up the message. I get the following error:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><b>"No JSON object could be decoded" <o:p></o:p></b></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> Let me step back a second.....here is an example of
the BINARY sent from the Erlang client (inside Mochiweb) to RabbitMQ:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>NOTE: I have simplified the call by just making a binary
called “Hello World” for “Payload”<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='color:red'>Payload =
<<"Hello World">>,<o:p></o:p></span></p>
<p class=MsoNormal>
Content = #content{class_id = 60,<o:p></o:p></p>
<p class=MsoNormal>
properties = amqp_util:basic_properties(),<o:p></o:p></p>
<p class=MsoNormal>
properties_bin = none, <o:p></o:p></p>
<p class=MsoNormal>
payload_fragments_rev = [Payload]<o:p></o:p></p>
<p class=MsoNormal>
},<o:p></o:p></p>
<p class=MsoNormal>
amqp_channel:cast(Channel, BasicPublish, Content),<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>When the Python JSON library (decoder.py) receives this I
can see the message is formatted like:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='color:red'>‘Hello World’<o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>But if I send to RabbitMQ like follows using PYTHON..<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>from carrot.messaging import Publisher<o:p></o:p></p>
<p class=MsoNormal>from carrot.connection import AMQPConnection<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>amqpconn = AMQPConnection(hostname="localhost",
port=5672, userid="guest",
password="guest",vhost="/")<o:p></o:p></p>
<p class=MsoNormal>publisher = Publisher(connection=amqpconn,
exchange="amq.direct", routing_key="a.b.c.*")<o:p></o:p></p>
<p class=MsoNormal>publisher.send('Hello World')<o:p></o:p></p>
<p class=MsoNormal>publisher.close()<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I get the following for the message in the Python JSON
library (decoder.py):<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='color:red'>‘”Hello World”’<o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><u>NOTE the subtle different between the two.....the first
one is ‘Hello World’ (from Erlang) and the second (from Python) is ‘”Hello
World”’<o:p></o:p></u></p>
<p class=MsoNormal><u><o:p><span style='text-decoration:none'> </span></o:p></u></p>
<p class=MsoNormal>I am just wondering if this is a “Unicode” thing or do I
need to do something to the Erlang BINARY before sending it to RabbitMQ?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I think this could also have to do with the BUILT IN JSON
library in Python 2.6......I will look into that.....<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Thanks for the help....much appreciated ;-)<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Lynton<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>