High Quality JMS Messaging.

jline

Starting with SwiftMQ 7.3.0, CLI uses JLine to provide a command history, command line editing and password character masking.

Actually there is nothing special to say about JLine. It should just work with your arrow keys on the common operating systems. However, if it doesn't work, you can switch it off by setting the following system property:

    java -cp (jars not shown) -Djline.terminal=jline.UnsupportedTerminal com.swiftmq.admin.cli.CLI smqp://localhost:4001 plainsocket@router1

Command Format

Since SwiftMQ 7.3.0 multiple commands can be executed at once. The delimiter between commands is a semicolon.

Example:

  sr router1;cc /sys$queuemanager/queues;lc

The default delimiter between command tokens is blank. To specify a command token which includes blanks, the token has to be enclosed in double quotes. To specify a single double quote inside a token, use 2 double quotes.

Example:

  set "my attribute" "my ""quoted value"""

Command Aliases

Command aliases are introduced in SwiftMQ 7.3.0 because users wanted to have their familiar command names, e.g. from Unix shells, like "cd" instead of our "cc" or "ls" instead of "lc" (list context) and so on. The following CLI command are to manage CLI aliases:

Syntax Description
aset <alias> <command> Define a CLI alias.
adel <alias> Delete a CLI alias.
alist [<alias>] List a single or all CLI aliases.
asave [<file>] Saves all defined CLI aliases into the specified file or, if a filename is not specified, into the default .init.cli file.

CLI command "aset" is used to set an alias. If the aliases is already defined, it is overwritten. The right <command> part can contain any CLI command as well as aliases and also parameters:

Example:

    aset quit exit
    aset ls lc
    aset cd cc
    aset nq sr router1;cd /sys$queuemanager/queues;new ${1};lc ${1}

The above "nq" aliases creates a new queue and references a parameter (Note that the "cd" alias is referenced here). These parameters are referenced as ${number} where "number" is the sequence number of the parameter, starting with 1. So the following CLI command creates a new queue "smsqueue" on router1 and shows the attributes after creation (the lc ${1} command):

    router1> nq smsqueue

    Entity:      Queue
    Description: Queue Definition

    Properties for this Entity:

    Name                                    Current Value
    --------------------------------------------------------------
    cache-size                              500
    cache-size-bytes-kb                     -1
    cleanup-interval                        120000
    duplicate-detection-backlog-size        2000
    duplicate-detection-enabled             true
    flowcontrol-start-queuesize             400
    max-messages                            -1
    persistence-mode                        as_message

    Entity contains no Sub-Entities.

    router1/sys$queuemanager/queues>

This queue uses the default values for its attributes. If I want to have an alias where I can specify a variable number of parameters, I use the ${*} place holder which puts all parameters at this position:

    aset nq sr router1;cd /sys$queuemanager/queues;new ${*}

So I can issue the following command:

    nq smsqueue cache-size 2000 flowcontrol-start-queuesize 1800 max-messages 20000

CLI command "adel" deletes an alias. A list of all defined aliases can be obtained by "alist":

Example:

    router1/sys$queuemanager/queues> alist

    Alias                            Command
    ------------------------------------------------------------------------
    al                               alist
    cd                               cc
    exec                             execute
    ls                               lc
    nq                               sr router1;cd /sys$queuemanager/queues;new ${*}
    q                                exit
    quit                             exit

    router1/sys$queuemanager/queues>

Command "asave" saves all aliases as "aset" commands into a file. See next section.

Init File

Starting with SwiftMQ 7.3.0, CLI executes an init file on startup which can contain "aset" CLI commands. So once a user has defined his own set of aliases, he uses the "asave" command to save it into the init file. This file is loaded during start and the aliases are available at any time:

Example:

    router1/sys$queuemanager/queues> alist

    Alias                            Command
    ------------------------------------------------------------------------
    al                               alist
    cd                               cc
    exec                             execute
    ls                               lc
    nq                               sr router;cd /sys$queuemanager/queues;new ${*};lc
    nt                               cd /sys$topic/topics;new xyz
    q                                exit
    quit                             exit

    router1/sys$queuemanager/queues> asave
    Saving aliases to file: /Users/kw/.init.cli
    router1/sys$queuemanager/queues> q
    imac-kw:unix kw$ ./cli

    Welcome to SwiftMQ!

    Username:
    Password:
    Trying to connect ... connected
    Router 'router1' is available for administration.
    Type 'help' to get a list of available commands.
    > alist

    Alias                            Command
    ------------------------------------------------------------------------
    al                               alist
    cd                               cc
    exec                             execute
    ls                               lc
    nq                               sr router;cd /sys$queuemanager/queues;new ${*};lc
    nt                               cd /sys$topic/topics;new xyz
    q                                exit
    quit                             exit

    >

The default file name of the init file is ".init.cli" and located under the user's home directory. Of course, CLI can be configured to use another init file by specifying the new name with system property "swiftmq.cli.init":

Example:

    java -cp (jars not shown) -Dswiftmq.cli.init=./myaliases.cli com.swiftmq.admin.cli.CLI smqp://localhost:4001 plainsocket@router1

To save the aliases into the above file, use:

    > asave ./myaliases.cli
    Saving aliases to file: ./myaliases.cli