Skip to content

Examples

Runnable example programs demonstrate common MQ administration tasks using mqrestadmin. Each example has a core function in the examples/ package and a standalone main.go entry point in examples/cmd/.

Prerequisites

Start the multi-queue-manager Docker environment and seed both queue managers:

./scripts/dev/mq_start.sh
./scripts/dev/mq_seed.sh

This starts two queue managers (QM1 on port 9463, QM2 on port 9464) on a shared Docker network. See local MQ container for details.

Environment variables

Variable Default Description
MQ_REST_BASE_URL https://localhost:9463/ibmmq/rest/v2 QM1 REST endpoint
MQ_REST_BASE_URL_QM2 https://localhost:9464/ibmmq/rest/v2 QM2 REST endpoint
MQ_QMGR_NAME QM1 Queue manager name
MQ_ADMIN_USER mqadmin Admin username
MQ_ADMIN_PASSWORD mqadmin Admin password
DEPTH_THRESHOLD_PCT 80 Queue depth warning threshold

Health check

Connects to one or more queue managers and checks QMGR status, command server availability, and listener state. Produces a pass/fail summary for each queue manager.

go run ./examples/cmd/healthcheck

See examples/healthcheck.go.

Queue depth monitor

Displays local queues with their current depth, flags queues approaching capacity, and sorts by depth percentage.

go run ./examples/cmd/depthmonitor

See examples/depthmonitor.go.

Channel status report

Displays channel definitions alongside live channel status, identifies channels that are defined but not running, and shows connection details.

go run ./examples/cmd/channelstatus

See examples/channelstatus.go.

Environment provisioner

Defines a complete set of queues, channels, and remote queue definitions across two queue managers, then verifies connectivity. Includes teardown.

go run ./examples/cmd/provisionenv

See examples/provisionenv.go.

Dead letter queue inspector

Checks the dead letter queue configuration, reports depth and capacity, and suggests actions when messages are present.

go run ./examples/cmd/dlqinspector

See examples/dlqinspector.go.

Queue status and connection handles

Demonstrates DISPLAY QSTATUS TYPE(HANDLE) and DISPLAY CONN TYPE(HANDLE) queries, showing how mqrestadmin flattens nested object response structures into uniform flat maps.

go run ./examples/cmd/queuestatus

See examples/queuestatus.go.