Preparing and running sample programs on UNIX and Linux

Before you run the sample programs on UNIX, we must first create a queue manager and also create the queues that we need. 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.

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. We 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 we 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. 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 we want the COBOL versions, we 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, we must provide 48 characters, padding with blank characters if necessary. Anything other than 48 characters causes the program to fail with reason code 2085.

Parent topic: Preparing and running the sample programs


Related reference