def pub(self, msg, topic_string, *opts): topic = pymqi.Topic(self.qmgr, topic_string=topic_string) topic.open(open_opts=pymqi.CMQC.MQOO_OUTPUT) if isinstance(msg, str) and not isinstance(msg, bytes): raise AttributeError('msg must be bytes (not str) to publish to topic.') # py3 topic.pub(msg, *opts) topic.close()
def getTopic(): logger.info('Connecting to Topic') try: t = pymqi.Topic(qmgr, topic_string=MQDetails[EnvStore.TOPIC_NAME]) t.open(open_opts=pymqi.CMQC.MQOO_OUTPUT) return t except pymqi.MQMIError as e: logger.error("Error getting topic") logger.error(e) return None
def pub(self, msg, topic_string, *opts): topic = pymqi.Topic(self.qmgr, topic_string=topic_string) topic.open(open_opts=pymqi.CMQC.MQOO_OUTPUT) topic.pub(msg, *opts) topic.close()