Search code examples
node.jsibm-mq

How to define outbound queue in codeengine's ibm mq sample program


Project link: https://github.com/ibm-messaging/mq-dev-patterns/blob/master/serverless/codeengine/clientapp/env.json

I'm looking to understand this sample project a bit better. Here are my questions:

  1. I'd like to know how this project defines both outbound queues and inbound queues
  2. What are the values "APP_USER" and"APP_PASSWORD" used for?
  3. What are the values "MODEL_QUEUE_NAME", "DYNAMIC_QUEUE_PREFIX" used for?
  4. I have a .TAB file that is typically used for .exe programs and I need to port over to this project. How can I accomplish this?
  5. I should also mention that I'm hoping to connect this sample program to a MQIPT. I have the host and port where the MQIPT lives would those values go into the "HOST", and "PORT" values within the env file?

I'm a beginner in MQ and I need some guidance to get my project rolling. Thank you.

I've pushed this project to IBM cloud's code engine and it is live but i cannot put anything to my desired queue or read anything from it. This is most likely due to the fact that the config isn't correct.


Solution

  • That env.json file is used as the default envrionment settings for the clientapp. All the values can be overridden using environment settings. The client app is an express / node.js that exposes the following endpoints:

    • / (Home Page) : Shows application version.
    • /mqput : Shows a form that puts a number of messages onto a queue.
    • /mpget : Shows a form that gets a number of messages from a queue.
    • /api/mqput : API route that the mqput page uses to put messages onto a queue.
    • /api/mqgetby : API route that the mqget page uses to get messages from a queue.
    • /api/mqgetbyid : API route that is used to get a message with a specific message id.

    The forms are used to trigger / test the apis. The apis can be used by other apps / observers to request the code to wake up and do something.

    The queue which it needs to do these actions are found in the env.json file. If you want you could modify the api code to expect a queue name as an input, you probably would want to add a list of queues into the forms, and pass the selected queue to the api endpoints.

    The code makes use of the IBM MQ node.js library ibmmq, and uses the app user and password as application credentials for the queue manager that it connects to.

    The MODEL_QUEUE_NAME and DYNAMIC_QUEUE_PREFIX aren't actually used by the code but were kept in to allow for the creation of routes that triggered a request / response action. For which a model queue is needed to create dynamic temporary queues.

    With respect to the MQIPT config, the CONNAME you use for the client connection needs to point to MQIPT, and if you're using TLS the client needs to trust the MQIPT certificate. So you'd use the MQIPT hostname and port in your env.json and if you're using TLS, you'll need to populate the keystores with the appropriate certificates.

    The CodeEngine sample doesn't look to include support for CCDT, but the underpinning MQ Node.JS library does export CCDTUrl. You'll need to modify the buildCNO() function in mqclient.js, to skip code that creates and sets mq.MQCD() in the same way that is done in the basicget.js sample.

    eg. This bit of logic is skipped if a CCDT is being used.

      if (! ccdtCheck()) {
        debug_info('CCDT URL export is not set, will be using json envrionment client connections settings for %s', MQDetails['QMGR']);
    
        // And then fill in relevant fields for the MQCD
        let cd = new mq.MQCD();
    
        cd.ConnectionName = `${MQDetails.HOST}(${MQDetails.PORT})`;
        cd.ChannelName = MQDetails.CHANNEL;
        debug_info('Connection is ', cd.ConnectionName);
    
        if (MQDetails.KEY_REPOSITORY) {
          debug_info('Will be running in TLS Mode');
    
          cd.SSLCipherSpec = MQDetails.CIPHER;
          cd.SSLClientAuth = MQC.MQSCA_OPTIONAL;
        }
    
        // Make the MQCNO refer to the MQCD
        cno.ClientConn = cd;
      }