MapMessages from Python to Java

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

MapMessages from Python to Java

ngcdan12
Hello,

I have a seperate application that was made in python that is currently using Active Mq to send map messages to a ACtive MQ server with a topic.  I then have another application written in java that has a message listener set up to receive messages from the same topic.  Now i have tested the Active Mq with pure java and I am able to send and receive mapMessages, and read their contents no problem with JMS API methods.  But when the python app uses active mqs built in methods to create a map message, and sends it to the server, I receive something, but am unable to read the contents of the message.  When I do something like a getString("marking") on the map message it comes up empty from the java side.  

So long problem short, problem is I can't read the mapMessage the Python app is sending out on my Java app.  

Thanks for any help you can provide.

Here is a code snibbet of the python mapMessage

        jmsMsg.setString("idString", msg.idStr)
        jmsMsg.setString("typeString", msg.typeStr)
        jmsMsg.setInt("marking", msg.site)
        jmsMsg.setInt("app", msg.app)

Here is the code snibbet of my Java message listener

private class ExListener implements MessageListener
    {
        public void onMessage(Message msg)
        {
        MapMessage mapMsg = (MapMessage) msg;
        try{System.out.println("getText() "+mapMsg.getString("marking"));
        }catch(JMSException e) {}
        }
    }

Reply | Threaded
Open this post in threaded view
|

Re: MapMessages from Python to Java

dejanb
Hi,

are you sure you're sending map messages from Python?

If you use Stomp protocol, you have to send your data xml or json encoded
and use "transformation" header to specify how data should be converted to
Java. I suggest you read this
http://cwiki.apache.org/confluence/display/ACTIVEMQ/Stomp#Stomp-Messagetransformationsand
look at StompTest (
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?view=markup)
for some more examples.

You can also use py-activemq (http://code.google.com/p/pyactivemq/) lib
which can use OpenWire and CMS API to send map messages naturally.

Cheers
--
Dejan Bosanac - http://twitter.com/dejanb

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Tue, Oct 27, 2009 at 2:04 AM, ngcdan12 <[hidden email]>wrote:

>
> Hello,
>
> I have a seperate application that was made in python that is currently
> using Active Mq to send map messages to a ACtive MQ server with a topic.  I
> then have another application written in java that has a message listener
> set up to receive messages from the same topic.  Now i have tested the
> Active Mq with pure java and I am able to send and receive mapMessages, and
> read their contents no problem with JMS API methods.  But when the python
> app uses active mqs built in methods to create a map message, and sends it
> to the server, I receive something, but am unable to read the contents of
> the message.  When I do something like a getString("marking") on the map
> message it comes up empty from the java side.
>
> So long problem short, problem is I can't read the mapMessage the Python
> app
> is sending out on my Java app.
>
> Thanks for any help you can provide.
>
> Here is a code snibbet of the python mapMessage
>
>        jmsMsg.setString("idString", msg.idStr)
>        jmsMsg.setString("typeString", msg.typeStr)
>        jmsMsg.setInt("marking", msg.site)
>        jmsMsg.setInt("app", msg.app)
>
> Here is the code snibbet of my Java message listener
>
> private class ExListener implements MessageListener
>    {
>        public void onMessage(Message msg)
>        {
>        MapMessage mapMsg = (MapMessage) msg;
>        try{System.out.println("getText() "+mapMsg.getString("marking"));
>        }catch(JMSException e) {}
>        }
>    }
>
>
> --
> View this message in context:
> http://www.nabble.com/MapMessages-from-Python-to-Java-tp26070536p26070536.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: MapMessages from Python to Java

ngcdan12
Hello Dejan,

Python is sending mapmessages directly to the MQ server :).

I am wondering about the Stomp protocol.  The example you listed below is for a Java implementaion of Stomp.  I am actually having a problem with the MapMessage being sent from the Python side.  So I would need to convert the mapmessage to an xml object, then, using stomp headers convert that object to a map message then send it correct?  The problem is I need to do that in Python and have been unable to find how to do so since all the examples are listed in java.  Could you clarify on using Python to create an xml object, convert to a map message then send it to Java?  Or is that not possible.  I have been looking at some modules like Stompy and stomppy but have not been able to create a working messageListener.

Thanks,

Dan

<quote author="Dejan Bosanac">
Hi,

are you sure you're sending map messages from Python?

If you use Stomp protocol, you have to send your data xml or json encoded
and use "transformation" header to specify how data should be converted to
Java. I suggest you read this
http://cwiki.apache.org/confluence/display/ACTIVEMQ/Stomp#Stomp-Messagetransformationsand
look at StompTest (
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?view=markup)
for some more examples.

You can also use py-activemq (http://code.google.com/p/pyactivemq/) lib
which can use OpenWire and CMS API to send map messages naturally.

Cheers
--
Dejan Bosanac - http://twitter.com/dejanb

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net

Reply | Threaded
Open this post in threaded view
|

Re: MapMessages from Python to Java

James Casey-2
Hi Dan,

for stomp.py, here's the code snippet to do what you need to do:

    dest='/queue/test.foo'
    conn = stomp.Connection([(HOST,PORT)])
    conn.start()
    conn.connect()
    message = {'field1' : 'foo', 'field2' : 'bar'}

    conn.send(message, destination=dest, headers={'transformation' :
'jms-map-xml'}, ack='auto')
    conn.disconnect()

Note we pass in a dict as the payload, along with the transformation
type 'jms-map-xml'.

cheers,

James.


2009/10/30 ngcdan12 <[hidden email]>:

>
> Hello Dejan,
>
> Python is sending mapmessages directly to the MQ server :).
>
> I am wondering about the Stomp protocol.  The example you listed below is
> for a Java implementaion of Stomp.  I am actually having a problem with the
> MapMessage being sent from the Python side.  So I would need to convert the
> mapmessage to an xml object, then, using stomp headers convert that object
> to a map message then send it correct?  The problem is I need to do that in
> Python and have been unable to find how to do so since all the examples are
> listed in java.  Could you clarify on using Python to create an xml object,
> convert to a map message then send it to Java?  Or is that not possible.  I
> have been looking at some modules like Stompy and stomppy but have not been
> able to create a working messageListener.
>
> Thanks,
>
> Dan
>
>
> Hi,
>
> are you sure you're sending map messages from Python?
>
> If you use Stomp protocol, you have to send your data xml or json encoded
> and use "transformation" header to specify how data should be converted to
> Java. I suggest you read this
> http://cwiki.apache.org/confluence/display/ACTIVEMQ/Stomp#Stomp-Messagetransformationsand
> look at StompTest (
> http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?view=markup)
> for some more examples.
>
> You can also use py-activemq (http://code.google.com/p/pyactivemq/) lib
> which can use OpenWire and CMS API to send map messages naturally.
>
> Cheers
> --
> Dejan Bosanac - http://twitter.com/dejanb
>
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
>
>
> --
> View this message in context: http://www.nabble.com/MapMessages-from-Python-to-Java-tp26070536p26123324.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: MapMessages from Python to Java

dejanb
James,

thanks for great example. Shouldn't it be jms-map-json in this example
however?

Dan, you can also take a look at PHP example here
http://stomp.fusesource.org/documentation/php/book.html#_message_transformation

Cheers
--
Dejan Bosanac - http://twitter.com/dejanb

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Fri, Oct 30, 2009 at 11:26 AM, James Casey <[hidden email]> wrote:

> Hi Dan,
>
> for stomp.py, here's the code snippet to do what you need to do:
>
>    dest='/queue/test.foo'
>    conn = stomp.Connection([(HOST,PORT)])
>    conn.start()
>    conn.connect()
>    message = {'field1' : 'foo', 'field2' : 'bar'}
>
>    conn.send(message, destination=dest, headers={'transformation' :
> 'jms-map-xml'}, ack='auto')
>    conn.disconnect()
>
> Note we pass in a dict as the payload, along with the transformation
> type 'jms-map-xml'.
>
> cheers,
>
> James.
>
>
> 2009/10/30 ngcdan12 <[hidden email]>:
> >
> > Hello Dejan,
> >
> > Python is sending mapmessages directly to the MQ server :).
> >
> > I am wondering about the Stomp protocol.  The example you listed below is
> > for a Java implementaion of Stomp.  I am actually having a problem with
> the
> > MapMessage being sent from the Python side.  So I would need to convert
> the
> > mapmessage to an xml object, then, using stomp headers convert that
> object
> > to a map message then send it correct?  The problem is I need to do that
> in
> > Python and have been unable to find how to do so since all the examples
> are
> > listed in java.  Could you clarify on using Python to create an xml
> object,
> > convert to a map message then send it to Java?  Or is that not possible.
>  I
> > have been looking at some modules like Stompy and stomppy but have not
> been
> > able to create a working messageListener.
> >
> > Thanks,
> >
> > Dan
> >
> >
> > Hi,
> >
> > are you sure you're sending map messages from Python?
> >
> > If you use Stomp protocol, you have to send your data xml or json encoded
> > and use "transformation" header to specify how data should be converted
> to
> > Java. I suggest you read this
> >
> http://cwiki.apache.org/confluence/display/ACTIVEMQ/Stomp#Stomp-Messagetransformationsand
> > look at StompTest (
> >
> http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?view=markup
> )
> > for some more examples.
> >
> > You can also use py-activemq (http://code.google.com/p/pyactivemq/) lib
> > which can use OpenWire and CMS API to send map messages naturally.
> >
> > Cheers
> > --
> > Dejan Bosanac - http://twitter.com/dejanb
> >
> > Open Source Integration - http://fusesource.com/
> > ActiveMQ in Action - http://www.manning.com/snyder/
> > Blog - http://www.nighttale.net
> >
> >
> > --
> > View this message in context:
> http://www.nabble.com/MapMessages-from-Python-to-Java-tp26070536p26123324.html
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: MapMessages from Python to Java

James Casey-2
Hi Dejan,

the stomp.py code only supports this single transformation type at the
moment, and turns the python dict into an XML string as follows:

  def __convert_dict(self, payload):
        """
        Encode python dictionary as <map>...</map> structure.
        """
        xmlStr = "<map>\n"
        for key in payload:
            xmlStr += "<entry>\n"
            xmlStr += "<string>%s</string>" % key
            xmlStr += "<string>%s</string>" % payload[key]
            xmlStr += "</entry>\n"
        xmlStr += "</map>"

        return xmlStr

Does this logic make sense ? When I look in the activemq console I see
a message body of "{field2=bar, field1=foo}" which makes me think it
's doing the right thing.

Just for completeness and to document it in the thread, to subscribe
and get these message bodies back again, you need to do :

      conn.subscribe(destination=dest, ack='auto',
headers={'transformation' : 'jms-object-xml'})

Currently this doesn't do the conversion back into a dict
automatically and will just return the xml in the message body, but
I'll look at how we can put that functionality into stomp.py

At the same time I'll look at adding additional json conversion to the
stomp.py library.

cheers,

James.


2009/10/30 Dejan Bosanac <[hidden email]>:

> James,
>
> thanks for great example. Shouldn't it be jms-map-json in this example
> however?
>
> Dan, you can also take a look at PHP example here
> http://stomp.fusesource.org/documentation/php/book.html#_message_transformation
>
> Cheers
> --
> Dejan Bosanac - http://twitter.com/dejanb
>
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
>
>
> On Fri, Oct 30, 2009 at 11:26 AM, James Casey <[hidden email]> wrote:
>
>> Hi Dan,
>>
>> for stomp.py, here's the code snippet to do what you need to do:
>>
>>    dest='/queue/test.foo'
>>    conn = stomp.Connection([(HOST,PORT)])
>>    conn.start()
>>    conn.connect()
>>    message = {'field1' : 'foo', 'field2' : 'bar'}
>>
>>    conn.send(message, destination=dest, headers={'transformation' :
>> 'jms-map-xml'}, ack='auto')
>>    conn.disconnect()
>>
>> Note we pass in a dict as the payload, along with the transformation
>> type 'jms-map-xml'.
>>
>> cheers,
>>
>> James.
>>
>>
>> 2009/10/30 ngcdan12 <[hidden email]>:
>> >
>> > Hello Dejan,
>> >
>> > Python is sending mapmessages directly to the MQ server :).
>> >
>> > I am wondering about the Stomp protocol.  The example you listed below is
>> > for a Java implementaion of Stomp.  I am actually having a problem with
>> the
>> > MapMessage being sent from the Python side.  So I would need to convert
>> the
>> > mapmessage to an xml object, then, using stomp headers convert that
>> object
>> > to a map message then send it correct?  The problem is I need to do that
>> in
>> > Python and have been unable to find how to do so since all the examples
>> are
>> > listed in java.  Could you clarify on using Python to create an xml
>> object,
>> > convert to a map message then send it to Java?  Or is that not possible.
>>  I
>> > have been looking at some modules like Stompy and stomppy but have not
>> been
>> > able to create a working messageListener.
>> >
>> > Thanks,
>> >
>> > Dan
>> >
>> >
>> > Hi,
>> >
>> > are you sure you're sending map messages from Python?
>> >
>> > If you use Stomp protocol, you have to send your data xml or json encoded
>> > and use "transformation" header to specify how data should be converted
>> to
>> > Java. I suggest you read this
>> >
>> http://cwiki.apache.org/confluence/display/ACTIVEMQ/Stomp#Stomp-Messagetransformationsand
>> > look at StompTest (
>> >
>> http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?view=markup
>> )
>> > for some more examples.
>> >
>> > You can also use py-activemq (http://code.google.com/p/pyactivemq/) lib
>> > which can use OpenWire and CMS API to send map messages naturally.
>> >
>> > Cheers
>> > --
>> > Dejan Bosanac - http://twitter.com/dejanb
>> >
>> > Open Source Integration - http://fusesource.com/
>> > ActiveMQ in Action - http://www.manning.com/snyder/
>> > Blog - http://www.nighttale.net
>> >
>> >
>> > --
>> > View this message in context:
>> http://www.nabble.com/MapMessages-from-Python-to-Java-tp26070536p26123324.html
>> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>> >
>> >
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: MapMessages from Python to Java

dejanb
Hi James,.

looks great. I was just confused with {'field1' : 'foo', 'field2' : 'bar'}
since it looks like JSON notation.

Cheers
--
Dejan Bosanac - http://twitter.com/dejanb

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Fri, Oct 30, 2009 at 12:53 PM, James Casey <[hidden email]> wrote:

> Hi Dejan,
>
> the stomp.py code only supports this single transformation type at the
> moment, and turns the python dict into an XML string as follows:
>
>  def __convert_dict(self, payload):
>        """
>        Encode python dictionary as <map>...</map> structure.
>        """
>        xmlStr = "<map>\n"
>        for key in payload:
>            xmlStr += "<entry>\n"
>            xmlStr += "<string>%s</string>" % key
>            xmlStr += "<string>%s</string>" % payload[key]
>            xmlStr += "</entry>\n"
>        xmlStr += "</map>"
>
>        return xmlStr
>
> Does this logic make sense ? When I look in the activemq console I see
> a message body of "{field2=bar, field1=foo}" which makes me think it
> 's doing the right thing.
>
> Just for completeness and to document it in the thread, to subscribe
> and get these message bodies back again, you need to do :
>
>      conn.subscribe(destination=dest, ack='auto',
> headers={'transformation' : 'jms-object-xml'})
>
> Currently this doesn't do the conversion back into a dict
> automatically and will just return the xml in the message body, but
> I'll look at how we can put that functionality into stomp.py
>
> At the same time I'll look at adding additional json conversion to the
> stomp.py library.
>
> cheers,
>
> James.
>
>
> 2009/10/30 Dejan Bosanac <[hidden email]>:
> > James,
> >
> > thanks for great example. Shouldn't it be jms-map-json in this example
> > however?
> >
> > Dan, you can also take a look at PHP example here
> >
> http://stomp.fusesource.org/documentation/php/book.html#_message_transformation
> >
> > Cheers
> > --
> > Dejan Bosanac - http://twitter.com/dejanb
> >
> > Open Source Integration - http://fusesource.com/
> > ActiveMQ in Action - http://www.manning.com/snyder/
> > Blog - http://www.nighttale.net
> >
> >
> > On Fri, Oct 30, 2009 at 11:26 AM, James Casey <[hidden email]>
> wrote:
> >
> >> Hi Dan,
> >>
> >> for stomp.py, here's the code snippet to do what you need to do:
> >>
> >>    dest='/queue/test.foo'
> >>    conn = stomp.Connection([(HOST,PORT)])
> >>    conn.start()
> >>    conn.connect()
> >>    message = {'field1' : 'foo', 'field2' : 'bar'}
> >>
> >>    conn.send(message, destination=dest, headers={'transformation' :
> >> 'jms-map-xml'}, ack='auto')
> >>    conn.disconnect()
> >>
> >> Note we pass in a dict as the payload, along with the transformation
> >> type 'jms-map-xml'.
> >>
> >> cheers,
> >>
> >> James.
> >>
> >>
> >> 2009/10/30 ngcdan12 <[hidden email]>:
> >> >
> >> > Hello Dejan,
> >> >
> >> > Python is sending mapmessages directly to the MQ server :).
> >> >
> >> > I am wondering about the Stomp protocol.  The example you listed below
> is
> >> > for a Java implementaion of Stomp.  I am actually having a problem
> with
> >> the
> >> > MapMessage being sent from the Python side.  So I would need to
> convert
> >> the
> >> > mapmessage to an xml object, then, using stomp headers convert that
> >> object
> >> > to a map message then send it correct?  The problem is I need to do
> that
> >> in
> >> > Python and have been unable to find how to do so since all the
> examples
> >> are
> >> > listed in java.  Could you clarify on using Python to create an xml
> >> object,
> >> > convert to a map message then send it to Java?  Or is that not
> possible.
> >>  I
> >> > have been looking at some modules like Stompy and stomppy but have not
> >> been
> >> > able to create a working messageListener.
> >> >
> >> > Thanks,
> >> >
> >> > Dan
> >> >
> >> >
> >> > Hi,
> >> >
> >> > are you sure you're sending map messages from Python?
> >> >
> >> > If you use Stomp protocol, you have to send your data xml or json
> encoded
> >> > and use "transformation" header to specify how data should be
> converted
> >> to
> >> > Java. I suggest you read this
> >> >
> >>
> http://cwiki.apache.org/confluence/display/ACTIVEMQ/Stomp#Stomp-Messagetransformationsand
> >> > look at StompTest (
> >> >
> >>
> http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?view=markup
> >> )
> >> > for some more examples.
> >> >
> >> > You can also use py-activemq (http://code.google.com/p/pyactivemq/)
> lib
> >> > which can use OpenWire and CMS API to send map messages naturally.
> >> >
> >> > Cheers
> >> > --
> >> > Dejan Bosanac - http://twitter.com/dejanb
> >> >
> >> > Open Source Integration - http://fusesource.com/
> >> > ActiveMQ in Action - http://www.manning.com/snyder/
> >> > Blog - http://www.nighttale.net
> >> >
> >> >
> >> > --
> >> > View this message in context:
> >>
> http://www.nabble.com/MapMessages-from-Python-to-Java-tp26070536p26123324.html
> >> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >> >
> >> >
> >>
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: MapMessages from Python to Java

ngcdan12
Hey guys,

Thanks for the response.  I made a Python script with the above code.  

import stomp

dest='MQ-X.1234.X-1.RadarTracks'
conn = stomp.Connection([('stomp:\\localhost',61616)])
conn.start()
conn.connect()
message = {'field1' : 'foo', 'field2' : 'bar'}

conn.send(message, destination=dest, headers={'transformation' :
    'jms-map-xml'}, ack='auto')
conn.disconnect()

When I run this script I get a
No handlers could be found for logger "stomp.py", warning message/error.  

I do not seem to be receiving any messages from my java message listener either.  Is this an error I should be worried about?  Also on my java listener I put the url as "stomp://localhost:61616"; which seems to run ok. I then connect to the broker using ActiveMQConnectionFactory class. I had to also enable the Stomp connector in the activemq.xml file stored in the activemq directory, by adding
<transportConnector name="stomp" uri="stomp://localhost:61616"/> 

Thanks,

Dan
Reply | Threaded
Open this post in threaded view
|

Re: MapMessages from Python to Java

James Casey-2
Hi Dan,

The code should look like :

import stomp

dest='/queue/MQ-X.1234.X-1.RadarTracks'
     # [1]
conn = stomp.Connection([('localhost',61616)])
       # [2]
conn.start()
conn.connect()
message = {'field1' : 'foo', 'field2' : 'bar'}

conn.send(message, destination=dest, headers={'transformation' :
   'jms-map-xml'}, ack='auto')
conn.disconnect()

Note:
[1] For STOMP you need to specific '/topic' or '/queue' as appropriate
in the destination

[2] You only need to specify 'localhost', no need for a full URL

For the logging warning, check what version of stomp.py you're using -
the issue with the logger is fixed in more recent versions (e.g.
2.0.4)

Finally, note that you can have your java consumer listen via openwire
and your python producer send via STOMP, you just need to add 2
network connectors (normally 'tcp://' connector is on port 61616 and
'stomp://' connector is on port 61613.

cheers,

James.

2009/11/2 ngcdan12 <[hidden email]>:

>
> Hey guys,
>
> Thanks for the response.  I made a Python script with the above code.
>
> import stomp
>
> dest='MQ-X.1234.X-1.RadarTracks'
> conn = stomp.Connection([('stomp:\\localhost',61616)])
> conn.start()
> conn.connect()
> message = {'field1' : 'foo', 'field2' : 'bar'}
>
> conn.send(message, destination=dest, headers={'transformation' :
>    'jms-map-xml'}, ack='auto')
> conn.disconnect()
>
> When I run this script I get a
> No handlers could be found for logger "stomp.py", warning message/error.
>
> I do not seem to be receiving any messages from my java message listener
> either.  Is this an error I should be worried about?  Also on my java
> listener I put the url as "stomp://localhost:61616"; which seems to run ok.
> I then connect to the broker using ActiveMQConnectionFactory class. I had to
> also enable the Stomp connector in the activemq.xml file stored in the
> activemq directory, by adding
> <transportConnector name="stomp" uri="stomp://localhost:61616"/>
>
> Thanks,
>
> Dan
> --
> View this message in context: http://old.nabble.com/MapMessages-from-Python-to-Java-tp26070536p26157767.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: MapMessages from Python to Java

ngcdan12
Great thanks for the help.

I can send and receive messages from python to java now :).

Dan

James Casey-2 wrote
Hi Dan,

The code should look like :

import stomp

dest='/queue/MQ-X.1234.X-1.RadarTracks'
     # [1]
conn = stomp.Connection([('localhost',61616)])
       # [2]
conn.start()
conn.connect()
message = {'field1' : 'foo', 'field2' : 'bar'}

conn.send(message, destination=dest, headers={'transformation' :
   'jms-map-xml'}, ack='auto')
conn.disconnect()

Note:
[1] For STOMP you need to specific '/topic' or '/queue' as appropriate
in the destination

[2] You only need to specify 'localhost', no need for a full URL

For the logging warning, check what version of stomp.py you're using -
the issue with the logger is fixed in more recent versions (e.g.
2.0.4)

Finally, note that you can have your java consumer listen via openwire
and your python producer send via STOMP, you just need to add 2
network connectors (normally 'tcp://' connector is on port 61616 and
'stomp://' connector is on port 61613.

cheers,

James.

2009/11/2 ngcdan12 <gameoperative2@hotmail.com>:
>
> Hey guys,
>
> Thanks for the response.  I made a Python script with the above code.
>
> import stomp
>
> dest='MQ-X.1234.X-1.RadarTracks'
> conn = stomp.Connection([('stomp:\\localhost',61616)])
> conn.start()
> conn.connect()
> message = {'field1' : 'foo', 'field2' : 'bar'}
>
> conn.send(message, destination=dest, headers={'transformation' :
>    'jms-map-xml'}, ack='auto')
> conn.disconnect()
>
> When I run this script I get a
> No handlers could be found for logger "stomp.py", warning message/error.
>
> I do not seem to be receiving any messages from my java message listener
> either.  Is this an error I should be worried about?  Also on my java
> listener I put the url as "stomp://localhost:61616"; which seems to run ok.
> I then connect to the broker using ActiveMQConnectionFactory class. I had to
> also enable the Stomp connector in the activemq.xml file stored in the
> activemq directory, by adding
> <transportConnector name="stomp" uri="stomp://localhost:61616"/>
>
> Thanks,
>
> Dan
> --
> View this message in context: http://old.nabble.com/MapMessages-from-Python-to-Java-tp26070536p26157767.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>