Code Comments
Programming Forum and web based access to our favorite programming groups.Hello, sorry for the potentially dumb question, but - would JPype make it possible for a CPython program to use JMS? It seems that JMS is going to become a standard for (java-based) MOM, so as an excellent middleware language it should be possible for CPython to somehow "talk" (and understand) JMS... TIA, Best regards Wolfgang Keller
Post Follow-up to this messageWolfgang Keller wrote: > Hello, > > sorry for the potentially dumb question, but - would JPype make it possibl e > for a CPython program to use JMS? It seems that JMS is going to become a > standard for (java-based) MOM, so as an excellent middleware language it > should be possible for CPython to somehow "talk" (and understand) JMS... > > TIA, > > Best regards > > Wolfgang Keller I am not very well versed in JMS, but unless it absolutely REQUIRE subclassing, JPype will allow you to make full use for it without problem. How to actually interpret the contents of the JMS message is left as an exercise to the reader ;) Steve
Post Follow-up to this messageHello, and thanks for your reply. > I am not very well versed in JMS, but unless it absolutely REQUIRE > subclassing, JPype will allow you to make full use for it without problem. > > How to actually interpret the contents of the JMS message is left as an > exercise to the reader ;) Err, does JPype not provide something for interfacing with Java like CTypes provides it for interfacing with C? I.e. working with Java/C types in Python as if they were Python variables? TIA, Regards Wolfgang Keller
Post Follow-up to this messageWolfgang Keller wrote: > Hello, > > and thanks for your reply. > > > > > > > > Err, does JPype not provide something for interfacing with Java like CType s > provides it for interfacing with C? I.e. working with Java/C types in > Python as if they were Python variables? > > TIA, > > Regards > > Wolfgang Keller Indeed it does. For the most part, Java classes can be used just like regular Python classes. What I meant is that JMS messages can contain just about ANYTHING. Serialized Java classes, XML, plain text, etc ... Of course, if a regular Java program cna generate/interptet the contents, A python+Jpype program will be able to do it too. Again, with the same caveat that JPype does not (yet) support subclassing Java classes in python. Steve Menard
Post Follow-up to this messageOn Tue, 2 Nov 2004 18:19:25 +0100, Wolfgang Keller <wolfgang.keller.nospam@gmx.de> wrote: >Hello, > >sorry for the potentially dumb question, but - would JPype make it possible >for a CPython program to use JMS? It seems that JMS is going to become a >standard for (java-based) MOM, so as an excellent middleware language it >should be possible for CPython to somehow "talk" (and understand) JMS... > Your question intrigued me, so I gave it a try. And the anwer (at least for JMS Publish/Subscribe TextMessages) is YES. The example I wrote is too long to include here, but you can get it at http://home.comcast.net/~david.g.mo...r/Jpypejms.zip. It includes: - Java classes for a publisher (src/messaging/JpypePublisher) and a subscriber (src/messaging/JpypeSubscriber). These Java classes, which do most of the dirty work of connecting to the JMS server, are used from python via jpype. - Java classes that test the publisher and subscriber (src/messaging/testJpepePublisher, src/messaging/testJpypeSubscriber) - A Java interface that is used by python for the JProxy - python scripts for publishing and subscribing - An build.xml for ant to build and run the Java classes The Java and python publishers and subscribers work in any reasonable combination (J pub/J sub, J pub/p sub, p pub/p sub, p pub/J sub, and even with multiple subscribers) Unzip to a conveniently located folder. You'll find a build.xml for ant to build the Java. You'll have to edit (in the testers and in the python scripts) the naming and connection factory stuff for your situation. You'll also have to edit the python scripts to correctly locate your jvm and other classpath information. Once you're correctly configured, you can use ant to build and/or execute the Java (type "ant help"). And once the Java is built, you can try the python versions. I can't imagine that this approach wouldn't work for JMS Queues. And while I haven't tested it, I don't see anything preventing the use of other message types (BinaryMessage, ObjectMessage,...). BTW, I don't detect any noticable slowdown in the python versions from the Java versions (probably because of the strightforward conversion of python strings to Java Strings). HTH, Dave
Post Follow-up to this messageDavid Morgenthaler wrote: > On Tue, 2 Nov 2004 18:19:25 +0100, Wolfgang Keller > <wolfgang.keller.nospam@gmx.de> wrote: > > > > > Your question intrigued me, so I gave it a try. And the anwer (at > least for JMS Publish/Subscribe TextMessages) is YES. > > The example I wrote is too long to include here, but you can get it at > http://home.comcast.net/~david.g.mo...r/Jpypejms.zip. It > includes: > - Java classes for a publisher (src/messaging/JpypePublisher) and a > subscriber (src/messaging/JpypeSubscriber). These Java classes, which > do most of the dirty work of connecting to the JMS server, are used > from python via jpype. > - Java classes that test the publisher and subscriber > (src/messaging/testJpepePublisher, src/messaging/testJpypeSubscriber) > - A Java interface that is used by python for the JProxy > - python scripts for publishing and subscribing > - An build.xml for ant to build and run the Java classes > > The Java and python publishers and subscribers work in any reasonable > combination (J pub/J sub, J pub/p sub, p pub/p sub, p pub/J sub, and > even with multiple subscribers) > > Unzip to a conveniently located folder. You'll find a build.xml for > ant to build the Java. You'll have to edit (in the testers and in the > python scripts) the naming and connection factory stuff for your > situation. You'll also have to edit the python scripts to correctly > locate your jvm and other classpath information. Once you're correctly > configured, you can use ant to build and/or execute the Java (type > "ant help"). And once the Java is built, you can try the python > versions. > > I can't imagine that this approach wouldn't work for JMS Queues. And > while I haven't tested it, I don't see anything preventing the use of > other message types (BinaryMessage, ObjectMessage,...). > > BTW, I don't detect any noticable slowdown in the python versions from > the Java versions (probably because of the strightforward conversion > of python strings to Java Strings). > > HTH, > Dave > Dave, This example is amazing! would you be willing to contribute it to a Jpype examples/recipe repository? I think such a place would be great for those starting to use JPype. And as my documentation is not so good (yet), good examples can only help. Thanks. Steve Menard
Post Follow-up to this messageOn Sat, 06 Nov 2004 13:19:49 -0500, Steve Menard <foo@bar.com> wrote: > >Dave, > >This example is amazing! would you be willing to contribute it to a >Jpype examples/recipe repository? I think such a place would be great >for those starting to use JPype. And as my documentation is not so good >(yet), good examples can only help. > >Thanks. > >Steve Menard Consider it contributed. I'm glad to (finally) give something back to c.l.py! Dave
Post Follow-up to this messageDavid Morgenthaler wrote: > On Sat, 06 Nov 2004 13:19:49 -0500, Steve Menard <foo@bar.com> wrote: > > > > > > Consider it contributed. I'm glad to (finally) give something back to > c.l.py! > > Dave Thank you very much! I will add it to the exampels directyory for the next release. Steve
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.