IBM Support

What options are available for putting the contents of a file as messages into an MQ queue (MFT, amqsputc, MA01 q.exe, MH06 MQFile2Msg, IH03 RFHUtil GUI)

Question & Answer


Question

You would like to put contents of a file as messages into an MQ queue and yo would like to know what options are available.

Answer

a) The tool recommended by IBM MQ Support from IBM MQ regarding the reading of the contents of a file and put the contents into a message in a queue, is the MQ Managed File Transfer (MFT).
For more information see the following section (aka file-to-message)
https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.2.0/com.ibm.mq.adm.doc/file_to_message.htm
IBM MQ 9.2.x / IBM MQ / Administering / Administering Managed File Transfer / 
Transferring data from files to messages
b) For simple scenarios, the MQ samples amqsput and amqsputc could be helpful.
Keep in mind that each line feed / carriage return in the file will correspond to a separate message.
b.1) File that has 1 line. The result is 1 message.
C:\> type file-1line.txt
This is a line from a file, to be put as message.
C:\temp\mq>amqsput Q1 QM92 < file-1line.txt
Sample AMQSPUT0 start
target queue is Q1
Sample AMQSPUT0 end
b.2) File that has 3 lines. The result is 3 messages.
C:\> type file-3lines.txt
Line 1 - This is a line from a file, to be put as message.
Line 2 - message 2.
Line 3 - message 3.
C:\temp\mq>amqsput Q1 QM92 < file-3lines.txt
Sample AMQSPUT0 start
target queue is Q1
Sample AMQSPUT0 end
b.3) This is a screen capture from MQ Explorer which shows the browse of the 4 messages that were put in the queue in b.1 and b.2.
 
image 8052
c) Some non-IBM-MQ tools are discussed next.
Please keep in mind that these tools are NOT supported by IBM MQ Support.
They are supported by the corresponding authors.
c.1) Line command: MQFile2Msg (SupportPac 
https://www.ibm.com/support/pages/mh06-websphere-mq-trace-tools
MH06: WebSphere MQ - Trace Tools + Java MQFile2Msg

Abstract:
This SupportPac provides a Java command line tool called mqtrcfrmt to aid in reading MQ traces.
It also includes a Java utility called MQFile2Msg to upload the contents of a file into a message.

Linux example:
/opt/mqm/java/jre64/jre/bin/java -Djava.library.path=/opt/mqm/java/lib64 MQFile2Msg –q TCZ.TEST1 –f msg1p29003 –m QM1 –o MQSTR –c 819 –e 273

Windows example:
"%MQ_JAVA_INSTALL_PATH%\jre\bin"\java -D"%MQ_JAVA_LIB_PATH%" MQFile2Msg –q Q1 –f my-test.txt –m QM92 –o MQSTR

c.2) Line command: q.exe (SupportPac MA01 q.exe program)
https://github.com/ibm-messaging/mq-q-qload
MA01 SupportPac ("q" program)
For more details, see the following article:
https://www.ibm.com/support/pages/node/6409580
How to put the contents of a file into a single message in MQ using the q.exe utility (old SupportPac MA01)
c.3) GUI: RFHutil (SupportPac IH03)
IH03: WebSphere Message Broker - Message display, test & performance utilities (RFHutil, RFHutilc)
(Original URL no longer available)
Please note:  This SupportPac is now in withdrawn status and will remain available for back-up purposes only.  
The code for IH03 now available from GitHub
This repository contains the rfhutil program, originally released in SupportPac IH03. Both source code and binaries are included.
- From the PDF manual for :
Chapter 3. Using the Display and Test Utility
  Reading and writing from/to a file or queue (Page 15)
.
- Contents of repository
This repository contains source code for the rfhutil program, managed as a Microsoft Visual Studio 2017 Solution. If you have VS 2017, then opening the RFHUtil.sln file will allow you to rebuild the program.
Pre-built copies of the programs (rfhutil for connections to a local queue manager, rfhutilc for MQ client connections) are under the bin\Release directory. 
They can be run directly but you may first need to run the setmqenv program to set the environment variables that allow you to locate the MQ runtime libraries.
- Download note: You need to visit the following web page to download individual components:
https://github.com/ibm-messaging/mq-rfhutil/tree/master/bin/Release
- Prerequisites
This SupportPac requires: MQ server or client.
Please note: RFHUtil requires either MQ or the MQ client installed to start up. For MQ client only customers please use RFHUtilc.exe (the client version) and for local bindings use use RFHUtil.exe.
- Running the programs may require that you run setmqenv to set a suitable environment for the programs to locate the MQ libraries.
- Technical support
Category 2 SupportPacs are provided in good faith and AS-IS. There is no warranty or further service implied or committed and any supplied sample code is not supported via IBM product service channels. (That is, it is NOT supported by the IBM MQ Support team)
+++ 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

ibm16409594