diff --git a/amq-message-python-library/MorphemicConnection.py b/amq-message-python-library/MorphemicConnection.py index 0160419cc1271ad6947f4b80fe21fa634a3c1865..10be3f84679abb4fdd7868fc81fe0fcbe9946119 100644 --- a/amq-message-python-library/MorphemicConnection.py +++ b/amq-message-python-library/MorphemicConnection.py @@ -42,6 +42,7 @@ class Connection: self.subscribe("/queue/%s" % destination ,self._build_id(destination,id),ack) def unsubscribe(self, topic,id): + if not self.conn: return self.conn.unsubscribe(self._build_id(topic,id)) diff --git a/amq-message-python-library/MorphemicListener.py b/amq-message-python-library/MorphemicListener.py index 638c153ce2caa3812132a43272ba3e266ae86079..7c38c4269ce4118570c8e0cf531de6e35fcb8121 100644 --- a/amq-message-python-library/MorphemicListener.py +++ b/amq-message-python-library/MorphemicListener.py @@ -24,11 +24,22 @@ class MorphemicListener(ConnectionListener): logging.debug("Unknown message %s ",res) pass + def has_topic_name(self,headers, string): + return headers.get('destination').startswith(string) + + def get_topic_name(self,headers): + return headers.get('destination').replace('/topic/','') + + + def on(self,headers, res): + logging.debug("Unknown message %s ",res) + pass def on_message(self, headers, body): logging.debug("Headers %s",headers) logging.debug(" %s",body) + res = json.loads(body) func_name='on_%s' % slugify(headers.get('destination').replace('/topic/',''), separator='_',) if hasattr(self,func_name):