def work_with_property(self, property_value, property_type):
        messageHandle_get = None
        queue_get = None
        queue_put = None
        try:

            value_length = self.get_value_length(property_type, property_value)

            cmho_put = pymqi.CMHO()
            messageHandle_put = pymqi.MessageHandle(self.qmgr, cmho_put)
            messageHandle_put.properties.set(self.msg_prop_name,
                                             property_value,
                                             value_length=value_length,
                                             property_type=property_type)

            pmo = pymqi.PMO(Version=pymqi.CMQC.MQPMO_CURRENT_VERSION)
            pmo.OriginalMsgHandle = messageHandle_put.msg_handle

            md_put = pymqi.MD(Version=pymqi.CMQC.MQMD_CURRENT_VERSION)

            queue_put = pymqi.Queue(self.qmgr, self.queue_name,
                                    pymqi.CMQC.MQOO_OUTPUT)
            queue_put.put(b'', md_put, pmo)

            queue_put.close()

            gmo = pymqi.GMO(Version=pymqi.CMQC.MQGMO_CURRENT_VERSION)
            gmo.Options = pymqi.CMQC.MQGMO_NO_WAIT | pymqi.CMQC.MQGMO_PROPERTIES_IN_HANDLE
            gmo.MatchOptions = pymqi.CMQC.MQMO_MATCH_MSG_ID

            cmho_get = pymqi.CMHO(Version=pymqi.CMQC.MQCMHO_CURRENT_VERSION)
            messageHandle_get = pymqi.MessageHandle(self.qmgr, cmho_get)
            gmo.MsgHandle = messageHandle_get.msg_handle
            md_get = pymqi.MD()
            md_get.MsgId = md_put.MsgId

            queue_get = pymqi.Queue(self.qmgr, self.queue_name,
                                    pymqi.CMQC.MQOO_INPUT_AS_Q_DEF)
            queue_get.get(None, md_get, gmo)
        finally:
            if queue_put:
                if queue_put.get_handle():
                    queue_put.close()

            if queue_get:
                if queue_get.get_handle():
                    queue_get.close()

        return messageHandle_get
Exemplo n.º 2
0
    def workWithProp(self):
        messageHandle_get = None
        try:
            cmho_put = pymqi.CMHO()
            messageHandle_put = pymqi.MessageHandle(self.qmgr, cmho_put)
            messageHandle_put.properties.set(self.msg_prop_name, self.msg_prop_value)
            
            pmo = pymqi.PMO()
            pmo.OriginalMsgHandle = messageHandle_put.msg_handle

            md_put = pymqi.MD()

            queue_put = pymqi.Queue(self.qmgr, self.queue_name, pymqi.CMQC.MQOO_OUTPUT)
            queue_put.put(b'', md_put, pmo)

            queue_put.close()


            gmo = pymqi.GMO()
            gmo.Options = pymqi.CMQC.MQGMO_NO_WAIT | pymqi.CMQC.MQGMO_PROPERTIES_IN_HANDLE 
            gmo.MatchOptions = pymqi.CMQC.MQMO_MATCH_MSG_ID

            cmho_get = pymqi.CMHO()
            messageHandle_get = pymqi.MessageHandle(self.qmgr, cmho_get)
            gmo.MsgHandle = messageHandle_get.msg_handle
            md_get = pymqi.MD()
            md_get.MsgId = md_put.MsgId

            queue_get = pymqi.Queue(self.qmgr, self.queue_name, pymqi.CMQC.MQOO_INPUT_AS_Q_DEF)
            queue_get.get(None, md_get, gmo)
        finally:
            if queue_put:
                if queue_put.get_handle():
                    queue_put.close()
            
            if queue_get:
                if queue_get.get_handle():
                    queue_get.close()

        return messageHandle_get        
Exemplo n.º 3
0
logging.basicConfig(level=logging.INFO)

queue_manager = 'QM1'
channel = 'DEV.APP.SVRCONN'
host = '127.0.0.1'
port = '1414'
queue_name = 'TEST.1'
message = 'Hello from Python!'
property_name = 'Property_1'
conn_info = '%s(%s)' % (host, port)
user = '******'
password = '******'

qmgr = pymqi.connect(queue_manager, channel, conn_info, user, password)

put_msg_h = pymqi.MessageHandle(qmgr)
put_msg_h.properties.set(property_name,
                         message)  # Default type is CMQC.MQTYPE_STRING

pmo = pymqi.PMO(
    Version=pymqi.CMQC.MQPMO_VERSION_3)  # PMO v3 is required properties
pmo.OriginalMsgHandle = put_msg_h.msg_handle

put_md = pymqi.MD(Version=pymqi.CMQC.MQMD_CURRENT_VERSION)

put_queue = pymqi.Queue(qmgr, queue_name)
put_queue.put(b'', put_md, pmo)

get_msg_h = pymqi.MessageHandle(qmgr)

gmo = pymqi.GMO(Version=pymqi.CMQC.MQGMO_CURRENT_VERSION)