Ejemplo n.º 1
0
    def setUp(self):
        """ Create a new queue manager (TESTPMQI).
        Must be run as a user that has 'mqm' access.

        """

        self.single_rfh2_message = \
        open("messages/single_rfh2.dat", "rb").read()
        self.single_rfh2_message_not_well_formed = \
        self.single_rfh2_message[0:117] + self.single_rfh2_message[121:]

        self.multiple_rfh2_message = \
        open("messages/multiple_rfh2.dat", "rb").read()
        self.multiple_rfh2_message_not_well_formed = \
        self.multiple_rfh2_message[0:117] + self.multiple_rfh2_message[121:]

        queue_manager = "QM01"
        channel = "SVRCONN.1"
        socket = "localhost(31414)"
        queue_name = "RFH2.TEST"

        self.qmgr = None
        try:
            if pymqi.__mqbuild__ == 'server':
                self.qmgr = pymqi.QueueManager('QM01')
            else:
                self.qmgr = pymqi.QueueManager(None)
                self.qmgr.connectTCPClient(queue_manager, pymqi.cd(), channel, socket)
            self.put_queue = pymqi.Queue(self.qmgr, queue_name)
            self.get_queue = pymqi.Queue(self.qmgr, queue_name)
            self.clear_queue(self.get_queue)
        except Exception as e:
            raise e
Ejemplo n.º 2
0
    def setUp(self):
        """ Create a new queue manager (TESTPMQI).
        Must be run as a user that has 'mqm' access.

        """

        self.single_rfh2_message = open(
            os.path.join(self.messages_dir, "single_rfh2.dat"), "rb").read()
        self.single_rfh2_message_not_well_formed = \
            self.single_rfh2_message[0:117] + self.single_rfh2_message[121:]

        self.multiple_rfh2_message = open(
            os.path.join(self.messages_dir, "multiple_rfh2.dat"), "rb").read()
        self.multiple_rfh2_message_not_well_formed = \
            self.multiple_rfh2_message[0:117] + self.multiple_rfh2_message[121:]

        queue_manager = config.MQ.QM.NAME
        channel = config.MQ.QM.CHANNEL
        conn_info = "%s(%s)" % (config.MQ.QM.HOST, config.MQ.QM.PORT)
        queue_name = config.MQ.QUEUE.QUEUE_NAMES['TestRFH2PutGet']

        self.qmgr = None
        if pymqi.__mqbuild__ == 'server':
            self.qmgr = pymqi.QueueManager(queue_manager)
        else:
            self.qmgr = pymqi.QueueManager(None)
            self.qmgr.connect_tcp_client(queue_manager,
                                         pymqi.cd(),
                                         channel,
                                         conn_info,
                                         user=config.MQ.QM.USER,
                                         password=config.MQ.QM.PASSWORD)
        self.put_queue = pymqi.Queue(self.qmgr, queue_name)
        self.get_queue = pymqi.Queue(self.qmgr, queue_name)
        self.clear_queue(self.get_queue)
Ejemplo n.º 3
0
    def setUpClass(cls):
        """Initialize test environment."""
        cls.prefix = os.environ.get('PYMQI_TEST_OBJECT_PREFIX', 'PYMQI.')

        # max length of queue names is 48 characters
        cls.queue_name = '{prefix}MSG.QUEUE'.format(prefix=config.MQ.QUEUE.PREFIX)
        cls.queue_manager = config.MQ.QM.NAME
        cls.channel = config.MQ.QM.CHANNEL
        cls.host = config.MQ.QM.HOST
        cls.port = config.MQ.QM.PORT
        cls.user = config.MQ.QM.USER
        cls.password = config.MQ.QM.PASSWORD

        cls.conn_info = '{0}({1})'.format(cls.host, cls.port)

        if pymqi.__mqbuild__ == 'server':
            cls.qmgr = pymqi.QueueManager(cls.queue_manager)
        else:
            cls.qmgr = pymqi.QueueManager(None)
            cls.qmgr.connectTCPClient(cls.queue_manager, pymqi.CD(), cls.channel,
                                      cls.conn_info, cls.user, cls.password)

        cls.pcf = pymqi.PCFExecute(cls.qmgr, response_wait_interval=15000)

        cls.version = cls.inquire_qmgr_version().decode()
Ejemplo n.º 4
0
def connect():
    logger.info('Establising Connection with MQ Server')
    try:
        cd = pymqi.CD()
        cd.ChannelName = MQDetails['CHANNEL']
        cd.ConnectionName = conn_info
        cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
        cd.TransportType = pymqi.CMQC.MQXPT_TCP

        # Create an empty SCO object, and optionally set TLS settings
        # if a cipher is set in the envrionment variables.
        sco = pymqi.SCO()
        if MQDetails['CIPHER']:
            cd.SSLCipherSpec = MQDetails['CIPHER']
            sco.KeyRepository = MQDetails['KEY_REPOSITORY']

        #options = pymqi.CMQC.MQPMO_NO_SYNCPOINT | pymqi.CMQC.MQPMO_NEW_MSG_ID | pymqi.CMQC.MQPMO_NEW_CORREL_ID
        options = pymqi.CMQC.MQPMO_NEW_CORREL_ID

        qmgr = pymqi.QueueManager(None)
        qmgr.connect_with_options(MQDetails['QMGR'],
                                  user=credentials['USER'],
                                  password=credentials['PASSWORD'],
                                  opts=options,
                                  cd=cd,
                                  sco=sco)
        return qmgr
    except pymqi.MQMIError as e:
        logger.error("Error connecting")
        logger.error(e)
        return None
Ejemplo n.º 5
0
    def setUpClass(cls):
        """Initialize test environment."""
        cls.prefix = os.environ.get('PYMQI_TEST_OBJECT_PREFIX', 'PYMQI.')

        # max length of queue names is 48 characters
        cls.queue_name = '{prefix}MSG.QUEUE'.format(
            prefix=config.MQ.QUEUE.PREFIX)
        cls.queue_manager = config.MQ.QM.NAME
        cls.channel = config.MQ.QM.CHANNEL
        cls.host = config.MQ.QM.HOST
        cls.port = config.MQ.QM.PORT
        cls.user = config.MQ.QM.USER
        cls.password = config.MQ.QM.PASSWORD

        cls.conn_info = '{0}({1})'.format(cls.host, cls.port)

        cls.qmgr = pymqi.QueueManager(None)
        try:
            cls.qmgr.connectTCPClient(cls.queue_manager, pymqi.CD(),
                                      cls.channel, cls.conn_info, cls.user,
                                      cls.password)
        except pymqi.MQMIError as ex:
            if ex.comp == pymqi.CMQC.MQCC_FAILED:
                raise ex

        cls.version = cls.inquire_qmgr_version().decode()
Ejemplo n.º 6
0
    def setUp(self):

        self.msg_prop_name = b"test_name"

        self.msg_prop_value_str = "test_valuetest_valuetest_valuetest_valuetest_value"
        self.msg_prop_value_bytes = b"test_valuetest_valuetest_valuetest_valuetest_value"
        self.msg_prop_value_bool = True
        self.msg_prop_value_int8 = -127
        self.msg_prop_value_int16 = -32768
        self.msg_prop_value_int32 = -2147483647
        self.msg_prop_value_int64 = -9223372036854775808
        self.msg_prop_value_float32 = 1.1754943508222875e-38
        self.msg_prop_value_float64 = 2.2250738585072014e-308

        # max length of queue names is 48 characters
        self.queue_name = "{prefix}MSG.PROP.QUEUE".format(
            prefix=config.MQ.QUEUE.PREFIX)
        self.queue_manager = config.MQ.QM.NAME
        self.channel = config.MQ.QM.CHANNEL
        self.host = config.MQ.QM.HOST
        self.port = config.MQ.QM.PORT
        self.user = config.MQ.QM.USER
        self.password = config.MQ.QM.PASSWORD

        self.conn_info = "{0}({1})".format(self.host, self.port)

        self.qmgr = pymqi.QueueManager(None)
        self.qmgr.connectTCPClient(self.queue_manager, pymqi.CD(),
                                   self.channel, self.conn_info, self.user,
                                   self.password)

        self.create_queue(self.queue_name)
Ejemplo n.º 7
0
def connect():
    global qmgr
    conn_info = '%s(%s)' % (args.host, args.port)
    if (not args.use_client_auth and not args.use_ssl):
        qmgr = pymqi.connect(args.queue_manager, args.channel, conn_info)
    elif (args.use_client_auth and not args.use_ssl):
        qmgr = pymqi.connect(args.queue_manager, args.channel, conn_info,
                             args.username, args.password)
    elif (args.use_ssl):
        cd = pymqi.CD()
        cd.ChannelName = bytes(args.channel, encoding='utf8')
        cd.ConnectionName = bytes(conn_info, encoding='utf8')
        cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
        cd.TransportType = pymqi.CMQC.MQXPT_TCP
        cd.SSLCipherSpec = bytes(args.cipherspec, encoding='utf8')
        sco = pymqi.SCO()
        sco.KeyRepository = bytes(args.server_cert, encoding='utf8')
        qmgr = pymqi.QueueManager(None)
        if (not args.use_client_auth):
            qmgr.connect_with_options(args.queue_manager, cd=cd, sco=sco)
        else:
            qmgr.connect_with_options(args.queue_manager,
                                      cd=cd,
                                      sco=sco,
                                      user=bytes(args.username,
                                                 encoding='utf8'),
                                      password=bytes(args.password,
                                                     encoding='utf8'))
    print("connection succesful")
Ejemplo n.º 8
0
    def test_connection_with_tls(self):
        """Test connection to QueueManager with TLS."""
        qmgr = pymqi.QueueManager(None)
        conn_info = pymqi.ensure_bytes('{0}({1})'.format(self.host, self.port))

        cd = pymqi.CD(
            Version=pymqi.CMQXC.MQCD_VERSION_7,  # pylint: disable=C0103
            ChannelName=self.tls_channel_name,
            ConnectionName=conn_info,
            SSLCipherSpec=self.cypher_spec)

        sco = pymqi.SCO(Version=pymqi.CMQC.MQSCO_VERSION_5,
                        KeyRepository=os.path.join(
                            self.key_repo_location_client,
                            self.certificate_label_client),
                        CertificateLabel=self.certificate_label_client)

        opts = pymqi.CMQC.MQCNO_HANDLE_SHARE_NO_BLOCK

        qmgr.connectWithOptions(self.queue_manager,
                                cd,
                                sco,
                                opts=opts,
                                user=self.user,
                                password=self.password)
        is_connected = qmgr.is_connected
        if is_connected:
            qmgr.disconnect()

        self.assertTrue(is_connected)
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
    def setUp(self):
        self.topic_string_template = "/UNITTEST/{prefix}/PUBSUB/{{type}}/{{destination}}/{{durable}}".format(
            prefix=config.MQ.QUEUE.PREFIX)
        self.subname_template = "{prefix}'s {{type}} {{destination}} {{durable}} Subscription".format(
            prefix=config.MQ.QUEUE.PREFIX)
        self.msg_template = "Hello World in the topic string \"{{topic_string}}\"".format(
        )
        # max length of queue names is 48 characters
        self.queue_name_template = "{prefix}_Q_TEST_PUBSUB_{{type}}_PROVIDED_{{durable}}".format(
            prefix=config.MQ.QUEUE.PREFIX)
        self.queue_manager = config.MQ.QM.NAME
        self.channel = config.MQ.QM.CHANNEL
        self.host = config.MQ.QM.HOST
        self.port = config.MQ.QM.PORT
        self.user = config.MQ.QM.USER
        self.password = config.MQ.QM.PASSWORD

        self.conn_info = "{}({})".format(self.host, self.port)

        self.qmgr = pymqi.QueueManager(None)
        self.qmgr.connectTCPClient(self.queue_manager, pymqi.CD(),
                                   self.channel, self.conn_info, self.user,
                                   self.password)

        # list of tuples (subscription, subscription descriptions) for tearDown() to delete after the test
        self.sub_desc_list = []
Ejemplo n.º 11
0
 def test_connect(self):
     # connecting with queue manager name needs MQSERVER set properly
     print(os.environ['MQSERVER'])
     qmgr = pymqi.QueueManager(None)
     self.assertFalse(qmgr.is_connected)
     qmgr.connect(self.qm_name)
     self.assertTrue(qmgr.is_connected)
     qmgr.disconnect()
Ejemplo n.º 12
0
 def test_connect_tcp_client(self):
     qmgr = pymqi.QueueManager(None)
     qmgr.connect_tcp_client(self.qm_name,
                             pymqi.cd(),
                             self.channel,
                             self.conn_info,
                             user=self.user,
                             password=self.password)
     self.assertTrue(qmgr.is_connected)
     qmgr.disconnect()
Ejemplo n.º 13
0
 def test_get_handle_connected(self):
     qmgr = pymqi.QueueManager(None)
     qmgr.connect_tcp_client(self.qm_name,
                             pymqi.cd(),
                             self.channel,
                             self.conn_info,
                             user=self.user,
                             password=self.password)
     handle = qmgr.get_handle()
     # assertIsInstance is available >= Python2.7
     self.assertTrue(isinstance(handle, int))
Ejemplo n.º 14
0
 def test_connect_tcp_client_conection_list(self):
     qmgr = pymqi.QueueManager(None)
     self.conn_info = '127.0.0.1(22),{0}'.format(self.conn_info)
     qmgr.connect_tcp_client(self.qm_name,
                             pymqi.cd(),
                             self.channel,
                             self.conn_info,
                             user=self.user,
                             password=self.password)
     self.assertTrue(qmgr.is_connected)
     qmgr.disconnect()
Ejemplo n.º 15
0
def get_connection():
    queue_manager = config['queue_manager']

    connector_descriptor = pymqi.CD()
    connector_descriptor.ChannelName = config['server_connection']
    connector_descriptor.ConnectionName = config['host_port']
    connector_descriptor.ChannelType = CMQC.MQCHT_CLNTCONN
    connector_descriptor.TransportType = CMQC.MQXPT_TCP

    qmgr = pymqi.QueueManager(None)
    qmgr.connect_with_options(queue_manager, connector_descriptor)
    return qmgr
Ejemplo n.º 16
0
 def test_inquire(self):
     qmgr = pymqi.QueueManager(None)
     qmgr.connect_tcp_client(self.qm_name,
                             pymqi.cd(),
                             self.channel,
                             self.conn_info,
                             user=self.user,
                             password=self.password)
     attribute = pymqi.CMQC.MQCA_Q_MGR_NAME
     expected_value = utils.py3str2bytes(self.qm_name)
     attribute_value = qmgr.inquire(attribute)
     self.assertEqual(len(attribute_value), pymqi.CMQC.MQ_Q_MGR_NAME_LENGTH)
     self.assertEqual(attribute_value.strip(), expected_value)
Ejemplo n.º 17
0
    def get_connection(self):
        queue_manager = self.config['queue_manager']

        connector_descriptor = pymqi.CD()
        connector_descriptor.ChannelName = self.server_channel
        connector_descriptor.ConnectionName = self.host_port
        connector_descriptor.ChannelType = CMQC.MQCHT_CLNTCONN
        connector_descriptor.TransportType = CMQC.MQXPT_TCP
        connector_descriptor.WaitInterval = 30 * 60

        qmgr = pymqi.QueueManager(None)
        qmgr.connect_with_options(queue_manager, connector_descriptor)
        return qmgr
Ejemplo n.º 18
0
 def test_put1(self):
     qmgr = pymqi.QueueManager(None)
     qmgr.connect_tcp_client(self.qm_name,
                             pymqi.cd(),
                             self.channel,
                             self.conn_info,
                             user=self.user,
                             password=self.password)
     input_msg = b'Hello world!'
     qmgr.put1(self.queue_name, input_msg)
     # now get the message from the queue
     queue = pymqi.Queue(qmgr, self.queue_name)
     result_msg = queue.get()
     self.assertEqual(input_msg, result_msg)
Ejemplo n.º 19
0
def get_ssl_connection(config):
    # type: (IBMMQConfig) -> QueueManager
    """
    Get the connection with SSL
    """
    cd = _get_channel_definition(config)
    cd.SSLCipherSpec = config.ssl_cipher_spec

    sco = pymqi.SCO()
    sco.KeyRepository = config.ssl_key_repository_location

    queue_manager = pymqi.QueueManager(None)
    queue_manager.connect_with_options(config.queue_manager_name, cd, sco)

    return queue_manager
Ejemplo n.º 20
0
    def __init__(self):
        threading.Thread.__init__(self)
        self.daemon = True

        cd = pymqi.CD()
        cd.ChannelName = channel
        cd.ConnectionName = listener
        cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
        cd.TransportType = pymqi.CMQC.MQXPT_TCP
        self.qm = pymqi.QueueManager(None)
        self.qm.connect_with_options(qm_name, opts=pymqi.CMQC.MQCNO_HANDLE_SHARE_NO_BLOCK,
                                   cd=cd)

        self.req_queue = pymqi.Queue(self.qm, request_queue_name)
        self.replyto_queue = pymqi.Queue(self.qm, replyto_queue_name)
Ejemplo n.º 21
0
    def queue_manager(self):
        if self._queue_manager is None:
            queue_manager = pymqi.QueueManager(None)
            cd = self._connection_options['cd']
            self.log.info(
                'Connecting to MQ: connection=%s | queue manager=%s | channel=%s | user=%s',
                cd.ConnectionName.decode('utf-8'),
                self.config.queue_manager,
                self.config.channel,
                self.config.mq_user,
            )
            queue_manager.connect_with_options(self.config.queue_manager, **self._connection_options)
            self._queue_manager = queue_manager

        return self._queue_manager
Ejemplo n.º 22
0
    def __init__(self):
        self.queue_manager = config.queue_manager
        self.channel = config.channel
        self.port = config.port
        self.host = config.host
        self.conn_info = config.conn_info
        self.queue_request_name = config.queue_request_name
        self.queue_response_name = config.queue_response_name

        cd = pymqi.CD()
        cd.ChannelName = self.channel
        cd.ConnectionName = self.conn_info
        cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
        cd.TransportType = pymqi.CMQC.MQXPT_TCP

        self.qmgr = pymqi.QueueManager(None)
        self.qmgr.connect_with_options(self.queue_manager, opts=pymqi.CMQC.MQCNO_HANDLE_SHARE_NO_BLOCK, cd=cd)
Ejemplo n.º 23
0
def get_ssl_connection(config):
    """
    Get the connection with SSL
    """
    cd = pymqi.CD()
    cd.ChannelName = config.channel
    cd.ConnectionName = config.host_and_port
    cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
    cd.TransportType = pymqi.CMQC.MQXPT_TCP
    cd.SSLCipherSpec = config.ssl_cipher_spec

    sco = pymqi.SCO()
    sco.KeyRepository = config.ssl_key_repository_location

    queue_manager = pymqi.QueueManager(None)
    queue_manager.connect_with_options(config.queue_manager, cd, sco)

    return queue_manager
Ejemplo n.º 24
0
def init_message_queue(cfg):
    ''' Initialize IBM message queue'''
    mq_conn_info = "%s(%s)" % (cfg['mq_host'], cfg['mq_port'])

    cd = pymqi.CD()
    cd.ChannelName = cfg['mq_channel']
    cd.ConnectionName = mq_conn_info
    cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
    cd.TransportType = pymqi.CMQC.MQXPT_TCP

    qmgr = pymqi.QueueManager(None)
    logger.debug("Initiating connection")
    qmgr.connect_with_options(cfg['mq_queue_manager'],
                              opts=pymqi.CMQC.MQCNO_HANDLE_SHARE_BLOCK,
                              cd=cd)
    logger.info("Connected to MQ at [{}]".format(cfg['mq_host']))

    return qmgr
Ejemplo n.º 25
0
def get_normal_connection(config):
    # type: (IBMMQConfig) -> QueueManager
    """
    Get the connection either with a username and password or without
    """
    channel_definition = _get_channel_definition(config)
    queue_manager = pymqi.QueueManager(None)

    if config.username and config.password:
        log.debug("connecting with username and password")

        kwargs = {'user': config.username, 'password': config.password, 'cd': channel_definition}

        queue_manager.connect_with_options(config.queue_manager_name, **kwargs)
    else:
        log.debug("connecting without a username and password")
        queue_manager.connect_with_options(config.queue_manager_name, channel_definition)
    return queue_manager
Ejemplo n.º 26
0
    def test_is_connected(self):
        """Makes sure the QueueManager's 'is_connected' property works as
        expected.
        """
        # uses a mock so no real connection to a queue manager will be
        # established - the parameters below are basically moot
        with Replacer() as r:
            queue_manager = uuid4().hex
            channel = uuid4().hex
            host = uuid4().hex
            port = "1431"
            conn_info = "%s(%s)" % (host, port)
            user = "******"
            password = "******"

            for expected in (True, False):

                # noinspection PyUnusedLocal
                def _connect_tcp_client(*ignored_args, **ignored_kwargs):
                    pass

                # noinspection PyUnusedLocal
                def _getattr(self2, name):
                    if expected:

                        class _DummyMethod(object):
                            pass

                        # The mere fact of not raising an exception will suffice
                        # for QueueManager._is_connected to understand it as an
                        # all's OK condition.
                        return _DummyMethod
                    else:
                        raise Exception()

                r.replace('pymqi.QueueManager.connect_tcp_client',
                          _connect_tcp_client)
                r.replace('pymqi.PCFExecute.__getattr__', _getattr)

                qmgr = pymqi.QueueManager(None)
                qmgr.connect_tcp_client(queue_manager, pymqi.cd(), channel,
                                        conn_info, user, password)

                eq_(qmgr.is_connected, expected)
Ejemplo n.º 27
0
def connect():
    logger.info('Establising Connection with MQ Server')
    try:
        cd = None
        if not EnvStore.ccdtCheck():
            logger.info(
                'CCDT URL export is not set, will be using json envrionment client connections settings'
            )

            cd = pymqi.CD(Version=pymqi.CMQXC.MQCD_VERSION_11)
            cd.ChannelName = MQDetails[EnvStore.CHANNEL]
            cd.ConnectionName = conn_info
            cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
            cd.TransportType = pymqi.CMQC.MQXPT_TCP

            logger.info('Checking Cypher details')
            # If a cipher is set then set the TLS settings
            if MQDetails[EnvStore.CIPHER]:
                logger.info('Making use of Cypher details')
                cd.SSLCipherSpec = MQDetails[EnvStore.CIPHER]

        # Key repository is not specified in CCDT so look in envrionment settings
        # Create an empty SCO object
        sco = pymqi.SCO()
        if MQDetails[EnvStore.KEY_REPOSITORY]:
            logger.info('Setting Key repository')
            sco.KeyRepository = MQDetails[EnvStore.KEY_REPOSITORY]

        #options = pymqi.CMQC.MQPMO_NO_SYNCPOINT | pymqi.CMQC.MQPMO_NEW_MSG_ID | pymqi.CMQC.MQPMO_NEW_CORREL_ID
        options = pymqi.CMQC.MQPMO_NEW_CORREL_ID

        qmgr = pymqi.QueueManager(None)
        qmgr.connect_with_options(MQDetails[EnvStore.QMGR],
                                  user=credentials[EnvStore.USER],
                                  password=credentials[EnvStore.PASSWORD],
                                  opts=options,
                                  cd=cd,
                                  sco=sco)
        return qmgr

    except pymqi.MQMIError as e:
        logger.error("Error connecting")
        logger.error(e)
        return None
Ejemplo n.º 28
0
    def setUp(self):
        # max length of queue names is 48 characters
        self.queue_name = "{prefix}PCF.QUEUE".format(
            prefix=config.MQ.QUEUE.PREFIX)
        self.queue_manager = config.MQ.QM.NAME
        self.channel = config.MQ.QM.CHANNEL
        self.host = config.MQ.QM.HOST
        self.port = config.MQ.QM.PORT
        self.user = config.MQ.QM.USER
        self.password = config.MQ.QM.PASSWORD

        self.conn_info = "{0}({1})".format(self.host, self.port)

        self.qmgr = pymqi.QueueManager(None)
        self.qmgr.connectTCPClient(self.queue_manager, pymqi.CD(),
                                   self.channel, self.conn_info, self.user,
                                   self.password)

        self.create_queue(self.queue_name)
Ejemplo n.º 29
0
    def setUp(self):

        self.msg_prop_name = utils.py3str2bytes("test_name")
        self.msg_prop_value = utils.py3str2bytes("test_valuetest_valuetest_valuetest_valuetest_value")

        # max length of queue names is 48 characters
        self.queue_name = "{prefix}.MSG.PROP.QUEUE".format(prefix=config.MQ.QUEUE.PREFIX)
        self.queue_manager = config.MQ.QM.NAME
        self.channel = config.MQ.QM.CHANNEL
        self.host = config.MQ.QM.HOST
        self.port = config.MQ.QM.PORT
        self.user = config.MQ.QM.USER
        self.password = config.MQ.QM.PASSWORD

        self.conn_info = "{0}({1})".format(self.host, self.port)

        self.qmgr = pymqi.QueueManager(None)
        self.qmgr.connectTCPClient(self.queue_manager, pymqi.CD(), self.channel, self.conn_info, self.user, self.password)

        self.create_queue(self.queue_name)
Ejemplo n.º 30
0
def connectmq_put(recv_mq, str1):
    host = recv_mq["ip"] + "(" + recv_mq["port"] + ")"

    qmgr = pymqi.QueueManager(None)
    qmgr.connect_tcp_client(recv_mq["recv_queue_manager"], pymqi.CD(), recv_mq["recv_channel"], host,
                            recv_mq["username"], recv_mq["password"])

    try:
        qmgr.connect_tcp_client(recv_mq["recv_queue_manager"], pymqi.CD(), recv_mq["recv_channel"], host,
                                recv_mq["username"], recv_mq["password"])


    except pymqi.MQMIError as e:
        if e.comp == pymqi.CMQC.MQCC_WARNING and e.reason == pymqi.CMQC.MQRC_ALREADY_CONNECTED:
            pass

    queue = pymqi.Queue(qmgr, recv_mq["recv_queue"])
    queue.put(str1)
    queue.close()
    qmgr.disconnect()