Beispiel #1
0
    def test_pubsub_admin_provided(self):
        topic_string = self.topic_string_template.format(
            type="ADMIN", destination="PROVIDED", durable="DURABLE")
        subname = self.subname_template.format(type="Admin",
                                               destination="Provided",
                                               durable="Durable")
        msg = self.msg_template.format(topic_string=topic_string)
        queue_name = self.queue_name_template.format(type="ADMIN",
                                                     durable="DURABLE")
        sub_desc = self.get_subscription_descriptor(subname, topic_string,
                                                    pymqi.CMQC.MQSO_RESUME)
        # create queue
        self.create_queue(queue_name)
        openOpts = pymqi.CMQC.MQOO_INPUT_AS_Q_DEF
        sub_queue = pymqi.Queue(self.qmgr, queue_name, openOpts)

        # register Subscription
        self.create_admin_subscription(pymqi.CMQC.MQDC_PROVIDED, subname,
                                       queue_name, topic_string)
        sub = pymqi.Subscription(self.qmgr)

        sub.sub(sub_desc=sub_desc, sub_queue=sub_queue)
        self.sub_desc_list = [(sub, sub_desc, queue_name)]
        # publish (put)
        self.pub(msg, topic_string)

        get_opts = self.create_get_opts()
        data = sub.get(None, pymqi.md(), get_opts)

        sub.close(sub_close_options=0, close_sub_queue=True)
        self.assertEqual(data, msg)
Beispiel #2
0
    def test_pubsub_admin_managed(self):
        topic_string = self.topic_string_template.format(type="ADMIN",
                                                         destination="MANAGED",
                                                         durable="DURABLE")
        subname = self.subname_template.format(type="Admin",
                                               destination="Managed",
                                               durable="Durable")
        msg = self.msg_template.format(topic_string=topic_string)
        queue_name = self.queue_name_template.format(type="ADMIN",
                                                     durable="DURABLE")
        sub_desc = self.get_subscription_descriptor(subname, topic_string,
                                                    pymqi.CMQC.MQSO_RESUME)

        # register Subscription
        self.create_admin_subscription(pymqi.CMQC.MQDC_MANAGED, subname,
                                       queue_name, topic_string)
        sub = pymqi.Subscription(self.qmgr)
        self.sub_desc_list = [(sub, sub_desc, None)]
        sub.sub(sub_desc=sub_desc)
        # publish (put)
        self.pub(msg, topic_string)

        get_opts = self.create_get_opts()
        data = sub.get(None, pymqi.md(), get_opts)

        sub.close(sub_close_options=0, close_sub_queue=True)
        self.assertEqual(data, msg)
Beispiel #3
0
def main():
    qmgr = pymqi.QueueManager()
    sub  = pymqi.Subscription(qmgr)
    sd   = pymqi.SD(Options=CMQC.MQSO_CREATE  |
                            CMQC.MQSO_RESUME  |
                            CMQC.MQSO_MANAGED |
                            CMQC.MQSO_DURABLE)
    sd.set_vs('SubName', 'rtExistingTopic')
    sd.set_vs('ObjectString', 'RT.EXISTING_SECURITY.QA')
    sub.sub(sd)
    
    try:
         while not run.isSet():
              msg = getMessage(sub, syncpoint=True)
              if msg:
                   try:
                        --%CHANGE HERE%
                        qmgr.commit()
                   except Exception, e:
                        qmgr.backout()
                        raise
    finally:
        sub.close(sub_close_options=CMQC.MQCO_KEEP_SUB,
                  close_sub_queue=True)
        qmgr.disconnect()
Beispiel #4
0
def getSubscription():
    logger.info('Connecting to Subscription')
    try:
        sub_desc = pymqi.SD()
        sub_desc["Options"] = pymqi.CMQC.MQSO_CREATE + pymqi.CMQC.MQSO_RESUME + \
            pymqi.CMQC.MQSO_DURABLE + pymqi.CMQC.MQSO_MANAGED
        sub_desc.set_vs("SubName", "MySub")
        sub_desc.set_vs("ObjectString", MQDetails['TOPIC_NAME'])

        sub = pymqi.Subscription(qmgr)
        sub.sub(sub_desc=sub_desc)
        return sub
    except pymqi.MQMIError as e:
        logger.error("Error getting queue")
        logger.error(e)
        return None
Beispiel #5
0
def topic_value(tname):
    #run = Event()
    msg = ''
    subname = ''
    fileobj = open('mq_topic.log','a+b')
    queue_manager = pmclientrc.QA_QUEUE_MANAGER
    queue_name = pmclientrc.QA_QUEUE_NAME
    channel = pmclientrc.QA_CHANNEL
    host = pmclientrc.QA_HOST
    port = pmclientrc.QA_PORT
    conn_info = "%s(%s)" % (host, port)
    qmgr = pymqi.QueueManager()
    qmgr.connect_tcp_client(queue_manager, pymqi.CD(), channel, conn_info)
    if tname == 'RT.EXISTING_SECURITY.QA':
        subname = 'existing'
    elif tname == 'RT.NEW_SECURITY.QA':
        subname = 'new_security'
    elif tname == 'RT.COLLAT':
        subname = 'collat'
    elif tname == 'RT.TICKET.QA.TOPIC':
        subname = 'ticket_topic'
    elif tname == 'RT.ORDER':
        subname = 'order'
    topicname = tname
    topic_string = re.sub(r'\.','/',topicname)
    sub  = pymqi.Subscription(qmgr)
    sd   = pymqi.SD(Options=CMQC.MQSO_CREATE  |
                            CMQC.MQSO_RESUME  |
                            CMQC.MQSO_MANAGED |
                            CMQC.MQSO_DURABLE)
    sd.set_vs('SubName', subname)
    sd.set_vs('ObjectString', topic_string)
    sub.sub(sd)
    msg = getMessage(sub, syncpoint=True)
		
    fileobj.write(subname + '|' +  msg+"\n")
    sub.close(sub_close_options=CMQC.MQCO_KEEP_SUB,
    close_sub_queue=True)
    qmgr.disconnect()
Beispiel #6
0
 def create_api_subscription(self):
     return pymqi.Subscription(self.qmgr)