Preparing and running the sample programs on IBM i
Before we can run the IBM MQ for IBM i sample programs, you must compile them as you would any other IBM MQ for IBM i applications. To do so, we can use the IBM i commands CRTRPGMOD and CRTPGM.
When you create the AMQ3xxx4 programs, you must specify BNDSRVPGM(QMQM/LIBMQM) in the CRTPGM command. Doing so includes the various IBM MQ procedures in your program.
The sample programs are provided in library QMQMSAMP as members of QRPGLESRC. They use the copy files provided in library QMQM, so make sure that this library is in the library list when you compile them. The RPG compiler gives information messages because the samples do not use many of the variables that are declared in the copy files.
Running the sample programs
We can use your own queues when you run the samples, or we can compile and run AMQSAMP4 to create some sample queues. The source for this program is shipped in file QCLSRC in library QMQMSAMP. It can be compiled using the CRTCLPGM command.
To call one of the sample programs, use a command like:CALL PGM(QMQMSAMP/AMQ3PUT4) PARM('Queue_Name','Queue_Manager_Name')Where Queue_Name and Queue_Manager_Name must be 48 characters in length, which you achieve by padding the Queue_Name and Queue_Manager_Name with the required number of blanks.
For the Inquire and Set sample programs, the sample definitions created by AMQSAMP4 cause the C versions of these samples to be triggered. If you want to trigger the RPG versions, you must change the process definitions SYSTEM.SAMPLE.ECHOPROCESS and SYSTEM.SAMPLE.INQPROCESS and SYSTEM.SAMPLE.SETPROCESS. We can use the CHGMQMPRC command (described in Change MQ Process (CHGMQMPRC) ) to do so, or edit and run AMQSAMP4 with the alternative definition.