Created
October 20, 2010 22:18
-
-
Save adamv/637450 to your computer and use it in GitHub Desktop.
Listen to a JMS topic on a Tibco bus.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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