Documentation ¶
Overview ¶
This is an example of a Go program that deals with unprocessable or "poison" messages on an IBM MQ
queue by moving them to a backout queue. As the message is moved to the backout queue
a dead-letter header is attached both to indicate the reason for the move, and to
permit a DLQ handler program to further process the message. *
The queue and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. *
The input queue should be defined with both BOTHRESH and BOQNAME values and
the backout queue must exist
DEF QL(DEV.QUEUE.1) BOTHRESH(3) BOQNAME(DEV.QUEUE.BACKOUT) REPLACE
DEF QL(DEV.QUEUE.BACKOUT) *
Each MQI call prints its success or failure. *
This is an example of a Go program to get messages from an IBM MQ
queue. It uses the asynchronous callback operation instead of using
a synchronous MQGET. *
The queue and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. *
Each MQI call prints its success or failure. *
This is a short sample to show how to connect to a remote queue manager in a Go program without requiring external client configuration such as a CCDT. Only the basic parameters are needed here - channel name and connection information - along with the queue manager name.
For example, run as
amqsconn QMGR1 "SYSTEM.DEF.SVRCONN" "myhost.example.com(1414)"
If the MQSAMP_USER_ID environment variable is set, then a userid/password flow is also made to authenticate to the queue manager.
There is no attempt in this sample to configure advanced security features such TLS.
If an error occurs, the error is reported.
This is a short sample to show how to connect to a remote queue manager in a Go program with a TLS connection without requiring external client configuration such as a CCDT. The basic parameters are still needed here - channel name and connection information - along with the queue manager name.
For example, run as
amqsconn QMGR1 "SYSTEM.SSL.SVRCONN" "myhost.example.com(1414)"
If the MQSAMP_USER_ID environment variable is set, then a userid/password flow is also made to authenticate to the queue manager.
If an error occurs, the error is reported.
This is an example of a Go program to put and get messages to an IBM MQ
queue while manipulating a Dead Letter Header *
The queue and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. *
This is an example of a Go program to browse messages from an IBM MQ
queue. *
The queue and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. *
The program loops until no more messages are on the queue, waiting for
at most 3 seconds for new messages to arrive. *
Each MQI call prints its success or failure. *
This is an example of a Go program to get messages from an IBM MQ
queue. *
The queue and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. *
The program loops until no more messages are on the queue, waiting for
at most 3 seconds for new messages to arrive. *
Each MQI call prints its success or failure. *
A MsgId can be provided as a final optional parameter to this command
in which case we try to retrieve just a single message that matches. *
This is an example of a Go program to inquire on some attributes of some IBM MQ
objects. The program looks at a nominated queue, and also at a NAMELIST *
The queue and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. * *
This is an example of a Go program to create and parse PCF messages. It
issues the equivalent of "DISPLAY Q(x) ALL". *
The queue manager name and the queue to inquire on can be given as parameters on the
command line. Defaults are coded in the program. It also accesses
SYSTEM.ADMIN.COMMAND.QUEUE and SYSTEM.DEFAULT.MODEL.QUEUE. *
The program loops until either the command responses indicate completion, or no more replies are on
the queue, waiting for at most 3 seconds for new messages to arrive. *
This is an example of a Go program to put and get messages to an IBM MQ
queue while manipulating the message properties *
While the main body of this sample is the same as the amqsput and amqsget
samples, the important functions to understand here are setProperties and
printProperties. *
The queue and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. *
This is an example of a Go program to publish messages to an IBM MQ
topic. *
The topic and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. *
A single message is published, containing a "hello" and timestamp.
Each MQI call prints its success or failure. *
This is an example of a Go program to put messages to an IBM MQ
queue. *
The queue and queue manager name can be given as parameters on the
command line. Defaults are coded in the program.
This sample also permits use of environment variables for the
parameters, which might be preferable in some container
deployments. *
A single message is put, containing a "hello" and timestamp.
Each MQI call prints its success or failure. The MsgId of the
put message is also printed so it can be used as an optional
selection criterion on the amqsget sample program. *
This is an example of a Go program to set some attributes of an IBM MQ
queue through the MQSET verb. The attributes that can be set are limited;
those limitations are described in the MQSET documentation. *
The queue and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. * *
This is an example of a Go program to subscribe to publications from an IBM MQ
topic. *
The topic and queue manager name can be given as parameters on the
command line. Defaults are coded in the program. *
The program loops until no more publications are available, waiting for
at most 3 seconds for new messages to arrive. *
Each MQI call prints its success or failure. *