[rabbitmq-discuss] RabbitMQ Consumer Error

Lynton Grice lynton.grice at logosworld.com
Mon Jul 13 06:31:43 BST 2009


Hi there,

 

I seemed to have solved the issue....it all had to do with the
"content_encoding"....so I replaced this:

 

Content = #content{class_id = 60,

                     properties = amqp_util:basic_properties(),

                     properties = Properties,

                     properties_bin = none,                 

                     payload_fragments_rev = [Payload]

                    },

 

With this:

 

Properties = #'P_basic'{content_type = <<"application/octet-stream">>,

                       content_encoding = <<"binary">>,

                      delivery_mode = 1,

                      priority = 0},

                Content = #content{class_id = 60,

                     properties = Properties,

                     properties_bin = none,                 

                     payload_fragments_rev = [Payload]

                    },

 

Now my Python consumer in CARROT is working 100% ;-)

 

Chat later

 

Lynton

From: rabbitmq-discuss-bounces at lists.rabbitmq.com
[mailto:rabbitmq-discuss-bounces at lists.rabbitmq.com] On Behalf Of Lynton
Grice
Sent: 12 July 2009 07:13 PM
To: rabbitmq-discuss at lists.rabbitmq.com
Subject: [rabbitmq-discuss] RabbitMQ Consumer Error

 

Hi there,

 

I wonder if someone can help me on this one. I am building the following
scenario:

 

Client -> Mochiweb -> RabbitMQ (via Erlang RabbitMQ Client code) -> Python
consumer (using the Python CARROT AMQP library)

 

I have everything working right until the Python consumer picks up the
message. I get the following error:

 

"No JSON object could be decoded" 

 

 Let me step back a second.....here is an example of the BINARY sent from
the Erlang client (inside Mochiweb) to RabbitMQ:

 

NOTE: I have simplified the call by just making a binary called "Hello
World" for "Payload"

 

Payload = <<"Hello World">>,

                Content = #content{class_id = 60,

                     properties = amqp_util:basic_properties(),

                     properties_bin = none, 

                     payload_fragments_rev = [Payload]

                    },

                amqp_channel:cast(Channel, BasicPublish, Content),

 

When the Python JSON library (decoder.py) receives this I can see the
message is formatted like:

 

'Hello World'

 

But if I send to RabbitMQ like follows using PYTHON..

 

from carrot.messaging import Publisher

from carrot.connection import AMQPConnection

 

amqpconn = AMQPConnection(hostname="localhost", port=5672, userid="guest",
password="guest",vhost="/")

publisher = Publisher(connection=amqpconn, exchange="amq.direct",
routing_key="a.b.c.*")

publisher.send('Hello World')

publisher.close()

 

I get the following for the message in the Python JSON library (decoder.py):

 

'"Hello World"'

 

NOTE the subtle different between the two.....the first one is 'Hello World'
(from Erlang) and the second (from Python) is '"Hello World"'

 

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?

 

I think this could also have to do with the BUILT IN JSON library in Python
2.6......I will look into that.....

 

Thanks for the help....much appreciated ;-)

 

Lynton

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20090713/b9f054e4/attachment.htm 


More information about the rabbitmq-discuss mailing list