Skip to content

Instantly share code, notes, and snippets.

@adamv
Created October 20, 2010 22:18
Show Gist options
  • Save adamv/637450 to your computer and use it in GitHub Desktop.
Save adamv/637450 to your computer and use it in GitHub Desktop.
Listen to a JMS topic on a Tibco bus.
#!/usr/bin/env jython -J-XstartOnFirstThread -Dpython.path=jms.jar:tibcrypt.jar:tibjms.jar
import time
from javax.jms import TopicConnectionFactory, MessageListener, Session
from com.tibco.tibjms import TibjmsQueueConnectionFactory, TibjmsTopicConnectionFactory
class Listener(MessageListener):
def onMessage(self, message):
try:
mt = message.getString("message_type")
print "Message: %s" % mt
# print ",".join(map(str, message.getMapNames()))
except e:
print "Error:"
print e
if __name__ == '__main__':
listener = Listener()
factory = TibjmsTopicConnectionFactory("ourbus.ourserver.ourdomain")
conn = factory.createTopicConnection()
sess = conn.createTopicSession(False, Session.AUTO_ACKNOWLEDGE)
topic = sess.createTopic("our_topic")
sub = sess.createSubscriber(topic)
sub.setMessageListener(listener)
conn.start()
print "Started..."
while True:
time.sleep(1)
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment