Preparing and running sample programs on UNIX and Linux

Before you run the sample programs on UNIX, you must first create a queue manager and also create the queues that you need. If you want to run COBOL samples, you might need to do some additional preparation.


The IBM MQ on UNIX and Linux systems sample files are in the directories listed in Table 1 if the defaults were used at installation time.

Table 1. Where to find the samples for IBM MQ on UNIX and Linux systems
Content Directory
source files MQ_INSTALLATION_PATH/samp
dead-letter queue handler source files MQ_INSTALLATION_PATH/samp/dlq
executable files MQ_INSTALLATION_PATH/samp/bin

MQ_INSTALLATION_PATH represents the high-level directory in which IBM MQ is installed.

The samples need a set of queues to work with. We can either use your own queues or run the sample MQSC file amqscos0.tst to create a set. To run the samples, either use the executable versions supplied or compile the source versions as you would any other applications, using an ANSI compiler.


Procedure

  1. Create a queue manager and set up the default definitions. You must do this before we can run any of the sample programs. For more information about creating a queue manager, see Administer IBM MQ. For information about configuring a queue manager to securely accept incoming connection requests from applications that are running in client mode, see Configure a queue manager to accept client connections on Windows, UNIX and IBM i.
  2. If you are not using your own queues, run the sample MQSC file amqscos0.tst to create a set of queues. To do this on UNIX and Linux systems, enter:
    runmqsc QManagerName <amqscos0.tst > /tmp/sampobj.out
    Check the sampobj.out file to ensure that there are no errors.
  3. If you want to use the COBOL versions of the Inquire, Set, and Echo examples, change the process definitions before you run these samples. For the Inquire, Set, and Echo examples, the sample definitions trigger the C versions of these samples. If you want the COBOL versions, you must change the process definitions:

    • SYSTEM.SAMPLE.INQPROCESS
    • SYSTEM.SAMPLE.SETPROCESS
    • SYSTEM.SAMPLE.ECHOPROCESS

    On Windows, do this by editing the amqscos0.tst file and changing the C executable file names to the COBOL executable file names before using the runmqsc command to run these samples.

  4. Run the sample programs. To run a sample, enter its name followed by any parameters, for example:
    amqsput myqueue qmanagername

    where myqueue is the name of the queue on which the messages are going to be put, and qmanagername is the queue manager that owns myqueue.

    For more information on the parameters that each of the samples expects, see the descriptions of the individual samples.Note: For the COBOL sample programs, when you pass queue names as parameters, you must provide 48 characters, padding with blank characters if necessary. Anything other than 48 characters causes the program to fail with reason code 2085.