Use the sample programs on Multiplatforms
These sample procedural programs are delivered with the product. The samples are written
in C and COBOL, and demonstrate typical uses of the Message Queue Interface (MQI).
The samples are not intended to demonstrate general programming techniques, so some error
checking that you might want to include in a production program is omitted.
The source code for all the samples is provided with the product; this source includes comments
that explain the message queuing techniques demonstrated in the programs.
For RPG programming, see
IBM® i Application Programming Reference
(ILE/RPG) .
The names of the samples start with the prefix amq . The fourth
character indicates the programming language, and the compiler where necessary:
s: C language
0: COBOL language on both IBM and Micro Focus
compilers
i: COBOL language on IBM compilers only
m: COBOL language on Micro Focus compilers only
The eighth character of the executable indicates whether the sample runs in local binding mode or
client mode. If there is no eighth character, then the sample runs in local bindings mode. If the
eighth character is 'c' then the sample runs in client mode.
Before we can run the sample applications, you must first create and configure a queue manager.
To set up the queue manager to accept client connections, see Configure a queue manager to accept client connections on Windows, UNIX and IBM i .
Features demonstrated in the sample programs on Multiplatforms
A collection of tables that show the techniques demonstrated by the IBM MQ sample programs.
Preparing and running the sample programs
After completing some initial preparation, we can then run the sample programs.
The API exit sample program
The sample API exit generates an MQI trace to a user-specified file with a prefix defined in the MQAPI_TRACE_LOGFILE environment variable.
The Asynchronous consumption sample program
The amqscbf sample program demonstrates the use of MQCB and MQCTL to consume messages from multiple queues asynchronously.
The Asynchronous Put sample program
Learn about running the amqsapt sample and the design of the Asynchronous Put sample program.
The Browse sample programs
The Browse sample programs browse messages on a queue using the MQGET call.
The Browser sample program
The Browser sample program reads and writes both the message descriptor and the message content fields of all the messages on a queue.
The CICS transaction sample
A sample CICS® transaction program is provided, named amqscic0.ccs for source code and amqscic0 for the executable version. We can build transactions using the standard CICS facilities.
The Connect sample program
The Connect sample program allows you to explore the MQCONNX call and its options from a client. The sample connects to the queue manager using the MQCONNX call, inquires about the name of the queue manager using the MQINQ call, and displays it. Also, learn about running the amqscnxc sample.
The Data-Conversion sample program
The data-conversion sample program is a skeleton of a data conversion exit routine. Learn about the design of the data-conversion sample.
Database coordination samples
Two samples are provided that demonstrate how IBM MQ can coordinate both IBM MQ updates and database updates within the same unit of work.
Dead-letter queue handler sample
A sample dead-letter queue handler is provided, the name of the executable version is amqsdlq. If you want a dead-letter queue handler that is different from RUNMQDLQ, the source of the sample is available for you to use as your base.
The Distribution List sample program
The Distribution List sample amqsptl0 gives an example of putting a message on several message queues. It is based on the MQPUT sample, amqsput0.
The Echo sample programs
The Echo sample programs echo a message from a message queue to the reply queue.
The Get sample programs
The Get sample programs get messages from a queue using the MQGET call.
High availability sample programs
The amqsghac, amqsphac, and amqsmhac high availability sample programs use automated client reconnection to demonstrate recovery following the failure of a queue manager. amqsfhac checks that a queue manager using networked storage maintains data integrity following a failure.
The Inquire sample programs
The Inquire sample programs inquire about some of the attributes of a queue using the MQINQ call.
The Inquire Properties of a Message Handle sample program
AMQSIQMA is a sample C program to inquire properties of a message handle from a message queue, and is an example of the use of the MQINQMP API call.
The Publish/Subscribe sample programs
The publish/subscribe sample programs demonstrate the use of the publish and subscribe features in IBM MQ.
The Publish Exit sample program
AMQSPSE0 is a sample C program of an exit to intercept a publication before it is delivered to a subscriber. The exit can then, for example, alter the message headers, payload or destination, or prevent the message being published to a subscriber.
The Put sample programs
The Put sample programs put messages on a queue using the MQPUT call.
The Reference Message sample programs
The Reference Message samples allow a large object to be transferred from one node to another (usually on different systems) without the need for the object to be stored on IBM MQ queues at either the source or the destination nodes.
The Request sample programs
The Request sample programs demonstrate client/server processing. The samples are the clients that put request messages on a target server queue that is processed by a server program. They wait for the server program to put a reply message on a reply-to queue.
The Set sample programs
The Set sample programs inhibit put operations on a queue by using the MQSET call to change the queue's InhibitPut attribute. Also, learn about the design of Set sample programs.
The TLS sample program
AMQSSSLC is a sample C program that demonstrates how to use the MQCNO and MQSCO structures to supply TLS client connection information on the MQCONNX call. This enables a client MQI application to provide the definition of its client connection channel and TLS settings at run time without a client channel definition table (CCDT).
The Triggering sample programs
The function provided in the triggering sample is a subset of that provided in the trigger monitor in the runmqtrm program.
Use the TUXEDO samples on UNIX and Windows
Learn about the Put and Get sample programs for TUXEDO, and building the server environment in TUXEDO.
Use the SSPI security exit on Windows
This topic describes how to use the SSPI channel-exit programs on Windows systems. The supplied exit code is in two formats: object and source.
Running the samples using remote queues
We can demonstrate remote queuing by running the samples on connected queue managers.
The Cluster Queue Monitoring sample program (AMQSCLM)
This sample uses the built-in IBM MQ cluster workload balancing features to direct messages to instances of queues that have consuming applications attached. This automatic direction prevents the build-up of messages on an instance of a cluster queue to which no consuming application is attached.
Sample program for Connection Endpoint Lookup (CEPL)
IBM MQ Connection Endpoint Lookup sample provides a simple yet powerful exit module that offers IBM MQ users a way to retrieve connection definitions from an LDAP repository such as Tivoli Directory Server.
Parent topic: Use the IBM MQ sample procedural programs
Related concepts
Related tasks