import time import sys import stomp class DQLListener(object): def on_error(self, headers, message): print 'received an error \n \n \n %s' % message def on_message(self, headers, message): start_ex_at = message.find('.SearchDomainSpecificLanguageException') ends_ex_at = message.find('') print '\n Exception: %s \n ' % message[start_ex_at+39:ends_ex_at] print 'received a message \n \n \n %s' % message conn=stomp.Connection([('localhost',61613)]) conn.add_listener(DQLListener()) conn.start() conn.connect(wait=True) conn.subscribe(destination='/queue/drugs_dlq_error', ack='auto') time.sleep(10) conn.disconnect()