CLI
Overview
The SwiftMQ CLI is a command-line interface for administrating SwiftMQ routers and their configuration. It supports interactive and script-based operation, allowing users to navigate the configuration tree, view and modify properties, and execute management commands. The CLI can be started via provided shell scripts, supports scripting, variable substitution, command aliases, and output redirection.
Startup and Invocation
The CLI is started using the provided shell scripts: ./cli, ./clis, or ./cliamqp. These scripts handle all necessary Java invocation and environment setup. The CLI requires the SMQP URL and the JNDI connection factory name as arguments, with an optional script file for batch execution. There is no interactive username/password prompt when a script file is provided; credentials can be passed via the cli.username and cli.password system properties.
./cli smqp://localhost:4001 QueueConnectionFactory
./cli smqp://localhost:4001 QueueConnectionFactory /path/to/script.cli
./clis smqp://localhost:4001 QueueConnectionFactory
./cliamqp amqp://localhost:5672 QueueConnectionFactory
Tree Navigation and Context
The CLI operates on a hierarchical configuration tree. Navigation is performed using commands such as cc <context> to change context, and sr <router> to switch between routers. The prompt reflects the current router and context, e.g., routername/context>. Contexts are specified as absolute paths, such as /sys$queuemanager/queues.
cc /sys$queuemanager/queues
sr router1
Viewing and Modifying Configuration
Once in the desired context, properties can be viewed and modified using CLI commands. The CLI supports commands to list entities, show and set properties, and invoke management operations (e.g., backup, shrink, activate, copy, move, remove, view). The available commands depend on the current context and router.
show
set propertyname value
view
backup
Scripting and Automation
The CLI supports script execution via the execute <filename> command or by specifying a script file at startup. Scripts are plain text files containing CLI commands, with lines starting with # treated as comments. Variable substitution can be enabled with substitute on, and variables are managed with the var command. Output can be redirected to a file using the output command. Aliases for commands can be defined, listed, and saved to a file.
execute /path/to/script.cli
substitute on
var myqueue testqueue
output results.txt
aset myalias cc /sys$queuemanager/queues
alist
asave aliases.cli
Router Availability and Reconnection
The CLI can display available routers with the ar command and wait for a router to become available using wr <router> [timeout]. If the connection to a router is lost and re-established (e.g., after a reboot), the CLI does not automatically restore the last router or context. Scripts or applications must handle reconnection by re-issuing the appropriate sr and cc commands.
ar
wr router1 10000