IBM Support

How to put the contents of a file into a single message in MQ using the q.exe utility (old SupportPac MA01)

Question & Answer


Question

You want to know the precise options for the q.exe utility (old SupportPac MA01) to put the entire contents of a text file into a message in an MQ queue.

Answer

The q.exe utility (old SupportPac MA01) can be downloaded from:
https://github.com/ibm-messaging/mq-q-qload
MA01 SupportPac ("q" program)
This SupportPac is NOT maintained by the MQ Support Team. It is supported by its author.

Caveat: The following is an informal comment, it is NOT an official announcement!!
Even though MQ 8.0 and 9.x are not mentioned in the list of supported versions, the SupportPac works well with MQ 8.0 and 9.x in test environments.

++ Syntax:
The readme file containts the syntax and the name is:
    ma01_readme.txt
The flags relevant for this article are:
-f<filename>
          Input file.
          Each line of the file will be put to output queue as a different
          message.
-F[+]<filename>
          Input/output file.
          Entire file will be put to the output queue as a single message.

++ Setup
In a test Windows machine the zip file was downloaded into the following directory:
       C:\MQ-SupportPac\MA01 Q program\
The q.exe to be execute is located in the subdirectory: 
       C:\MQ-SupportPac\MA01 Q program\V6.0\Windows

++ Examples
1.a) Example of reading the whole contents of a file (the README file for this SupportPac) and placing it into a single message (using flag -F)
Notes on the options:
     -o<Q>     The name of the Output Queue name (if any)
     -m<QMgr>  The name of the Queue Manager to connect to if not the default.
     -F<filename> Input/output file. Entire file will be put to the output queue as a single message.
Showing baseline that queue Q1 is empty (CURDEPTH = 0)
C:\> runmqsc QM92
display qlocal(Q1) curdepth
     3 : display qlocal(Q1) curdepth
AMQ8409I: Display Queue details.
   QUEUE(Q1)                               TYPE(QLOCAL)
   CURDEPTH(0)
Go to the directory where q.exe is located:   
cd C:\MQ-SupportPac\MA01 Q program\V6.0\Windows
Issue the q.exe command:
  q.exe -o Q1 -m QM92 -F "C:\MQ-SupportPac\MA01 Q program V6\ma01_readme.txt"
  MQSeries Q Program by Paul Clarke [ V6.0.0 Build:May  1 2012 ]
  Connecting ...connected to 'QM92'.
1.b) We can use the MQ sample "amqsbcg" to browse the queue and verify that the entire contents of the file was placed inside a single message:
Notice that this utility will show the full length of the contents:
      length - 25061 of 25061 bytes
This number corresponds to the file size shows by the "dir" command for the readme file.
Showing that queue Q1 has 1 message (CURDEPTH = 1)
C:\> runmqsc QM92
display qlocal(Q1) curdepth
     3 : display qlocal(Q1) curdepth
AMQ8409I: Display Queue details.
   QUEUE(Q1)                               TYPE(QLOCAL)
   CURDEPTH(1)
C:\> amqsbcg Q1 QM92
...
       Format : 'MQSTR   '
     ...
     ****   Message      ****
      length - 25061 of 25061 bytes
     00000000:  202D 2D2D 2D2D 2D2D 2D2D 2D2D 2D2D 2D2D ' ---------------'
     00000010:  2D2D 2D2D 2D2D 2D2D 2D2D 2D2D 2D2D 2D2D '----------------'
Notice that the file size is 25061 and that the size of the message is also 25601 bytes. 
1.c) NOTE if using MQ Explorer: explanation about "apparent" truncation to 1,000 bytes when using MQ Explorer
In this test, the README file for this SupportPac has a byte size is:
     C:\MQ-SupportPac\MA01 Q program>dir *.txt
     05/01/2012  11:55 AM            25,061 ma01_readme.txt
However, when using the MQ Explorer and browsing the message that was put via the q.exe, MQ Explorer will show that there are only 1,000 bytes in the message, which causes confusion because it was asserted in an earlier bullet item, that the size of the contents was shown via the sample amqsbcg to be 25061 bytes
The reason for this apparent truncation, is that by default, the MQ Explorer will show ONLY UP TO A MAXIMUM of 16,384 bytes for each message (the default is 1,000)
The MQ Explorer is ONLY truncating the cached message in MQ Explorer to a visible portion of 1,000 bytes, but it is NOT truncating the real message that is sitting in the queue inside the queue manager.
The default maximum of bytes to shown for each message in MQ Explorer can be changed via:
MQ Explorer > Window > Preferences > MQ Explorer > Messages
   Top Section "Browsing limits"
      Max data bytes displayed: 1000
 
2) For completeness, this is another example of using q.exe, with a different flag but similar flag: -f
Example of reading the whole contents of a file (the README file for this SupportPac) and placing it into MANY messages (one message per line in the file).
Notes on the options:
   -o<Q>     The name of the Output Queue name (if any)
   -m<QMgr>  The name of the Queue Manager to connect to if not the default.
   -f<filename> Input file.    Each line of the file will be put to output queue as a different  message.
q.exe -o Q1 -m QM92 -f "C:\MQ-SupportPac\MA01 Q program V6\ma01_readme.txt"
Notice that the following runmqsc command will show that there are many messages in the queue Q1, as a result of the above command: 653 (652 from the 652 lines in the file, plus 1 from the previous attempt of q.exe)
     display qlocal(q1) curdepth
          1 : display qlocal(q1) curdepth
     AMQ8409: Display Queue details.
        QUEUE(Q1)                               TYPE(QLOCAL)
        CURDEPTH(653)
+++ end +++

[{"Line of Business":{"code":"LOB45","label":"Automation"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSYHRD","label":"IBM MQ"},"ARM Category":[{"code":"a8m50000000ClNeAAK","label":"Messages"}],"ARM Case Number":"TS004907135","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Document Information

Modified date:
28 January 2021

UID

ibm16409580