sending messages to TIBCO using Jython console

Using Hermes with Tibco EMS and Enterprise JMS

sending messages to TIBCO using Jython console

Postby MartinF » Thu Oct 08, 2009 7:27 am

Hello everyone,
I am trying to push some xml messages to TIBCO queue (or topic) using a Jython console and processes described in:
http://www.hermesjms.com/confluence/dis ... Properties, that's in my case:
....
hermes = browser.getContext().lookup("Hermes_Session")
context = hermes.createContext()
topic = context.lookup('"MY.SAMPLE.TOPIC") /*this is line 8*/
context.close()
...
But I still got following error even when I tried to push messages /just for a test/ to a EMS queue (f.i. queue = context.lookup('"MY.SAMPLE.QUEUE")), or when I changed the critical row to topic = context.lookup('"TOPIC/MY.SAMPLE.TOPIC").
My error looks like this:
Traceback (innermost last): File "D:\.hermes\reproces.sh", line 8, in ? AttributeError: 'NoneType' object has no attribute 'lookup'

I also tried:
...
hermes = HermesBrowser.getBrowser().getContext()
context = hermes.lookup("Hermes_Session")
topic = context.lookup('"MY.SAMPLE.TOPIC") /*let's say, now this is line 9*/
...
Then I got this error:
Traceback (innermost last): File "D:\.hermes\reproces_topic.sh", line 9, in ? AttributeError: lookup

But when I tried send som text message (without properties) through Hermes: Messages/Send Text Messages, or tried an example in http://www.hermesjms.com/confluence/dis ... t+Messages - it all worked.

So it seems like I just cannot make a connection to proper TIBCO queue or topic through Jython.
Please, can you explain me what am I doing wrong (I'm quite new to this)?
Thanks a lot in advance!

Martin
MartinF
 
Posts: 3
Joined: Wed Oct 07, 2009 1:09 pm

Re: sending messages to TIBCO using Jython console

Postby Colin » Mon Oct 12, 2009 12:47 pm

Are you using JNDI to configure JMS?

Try also replacing:

context = hermes.createContext()
topic = context.lookup('"MY.SAMPLE.TOPIC") /*this is line 8*/
context.close()

with

topic = hermes.createTopic("MY.SAMPLE.TOPIC") to bypass any JNDI and talk directly to the JMS Session.createTopic() method.

Regards,

Colin.
Colin
Site Admin
 
Posts: 835
Joined: Sun Sep 19, 2004 4:49 pm
Location: London, UK

Re: sending messages to TIBCO using Jython console

Postby MartinF » Mon Oct 12, 2009 4:06 pm

Hello, thank you fo your answer.
Yes, createTopic works fine while testing.. but I am affraid it is creating a new topic instance and when I will try it on production environment, it will create a new instance of the topic, each time i'll use the command (or at least I expect it to happen), and therefore I am afraid it will purge the actual topic and delete all possible present messages that's means I'm affraid they will be lost).
Or is this not going to happen?
I am sorry for this quite simple question, but i haven't found the proper answer for my worries in documentation... and I need to be sure:-(

Btw. I've created a TIBCO session as it was descibed in the demonstrative video - well I was not able to create proper JNDI Initial Context (or i dont know exactly how to configure it - is there an example somewhere?).
I think the creation of context from the session is my problem...

Thank you.
Regards,
Martin
MartinF
 
Posts: 3
Joined: Wed Oct 07, 2009 1:09 pm

Re: sending messages to TIBCO using Jython console

Postby Colin » Mon Oct 12, 2009 5:37 pm

Hi Martin,

When you create a topic object in your client VM via the JMS interface you are not creating another instance of the topic on the EMS server - there is only a single administered topic. The JMS topic object is just a reference to that in the server. I think the admin command in the EMS command tool is "show topics" or similar to see the topics. If you're not sure, try creating a browse (i.e. subscription) in Hermes and then run your python a few times - even though you create several JMS topic objects you send all the messages to the same EMS topic.

The code I've shown you should work fine with no side affects however check the EMS server to convince yourself.

Checking the Hermes website, I've not got an example of using JNDI with EMS so can't share one with you right now. If I get a chance to create one soon I'll post here.

Regards,

Colin.
Colin
Site Admin
 
Posts: 835
Joined: Sun Sep 19, 2004 4:49 pm
Location: London, UK

Re: sending messages to TIBCO using Jython console

Postby MartinF » Tue Oct 13, 2009 7:36 am

Hello, thank you for your answers!
This all sounds to be rational, and I don't see a problem anymore. This really should work.

Regards,
Martin
MartinF
 
Posts: 3
Joined: Wed Oct 07, 2009 1:09 pm


Return to Tibco EMS

Who is online

Users browsing this forum: No registered users and 1 guest