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", portV72, 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/20090712/50856736/attachment.htm

Search Discussions

  • Lynton Grice at Jul 13, 2009 at 5:31 am
    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", portV72, 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
  • Alexis Richardson at Jul 17, 2009 at 11:02 am
    Excellent - have you mentioned this to the Carrot folks?


    On Mon, Jul 13, 2009 at 6:31 AM, Lynton
    Gricewrote:
    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", portV72, 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





    _______________________________________________
    rabbitmq-discuss mailing list
    rabbitmq-discuss at lists.rabbitmq.com
    http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
  • Lynton Grice at Jul 17, 2009 at 2:09 pm
    Hi Alexis,

    I will drop the Carrot guys the message ;-)

    Chat later

    Lynton

    -----Original Message-----
    From: Alexis Richardson [mailto:alexis.richardson at gmail.com]
    Sent: 17 July 2009 01:02 PM
    To: Lynton Grice
    Cc: rabbitmq-discuss at lists.rabbitmq.com
    Subject: Re: [rabbitmq-discuss] RabbitMQ Consumer Error

    Excellent - have you mentioned this to the Carrot folks?


    On Mon, Jul 13, 2009 at 6:31 AM, Lynton
    Gricewrote:
    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", portV72, 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





    _______________________________________________
    rabbitmq-discuss mailing list
    rabbitmq-discuss at lists.rabbitmq.com
    http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprabbitmq-discuss @
categoriesrabbitmq
postedJul 12, '09 at 5:13p
activeJul 17, '09 at 2:09p
posts4
users2
websiterabbitmq.com
irc#rabbitmq

2 users in discussion

Lynton Grice: 3 posts Alexis Richardson: 1 post

People

Translate

site design / logo © 2022 Grokbase