Skip to main content
Skip table of contents

CLI Message Interface

Overview

The CLI Message Interface accepts CLI commands via TextMessages received from a queue. The messages can contain multiple CLI commands, separated by linefeeds (\n). The commands are executed and the result will be returned to the sending client if JMSReplyTo is set in the request message.

All CLI commands are supported, except sr, ar, wr, execute, echo and CLI alias commands.

If authentication of the Management Swiftlet is enabled, the very first command of a CLI command set in a TextMessage must be the authenticate command. The very last command of a CLI command set must be the exit command.

Example:

CODE
        authenticate secret
        cc .env
        lc router-memory-list/router1
        exit

returns:

CODE
        router1> cc .env
        router1/.env> lc router-memory-list/router1

        Entity:      Router Memory
        Description: Router Memory

        Properties for this Entity:

        Name                                    Current Value
        --------------------------------------------------------------
        free-memory (R/O)                       81866
        total-memory (R/O)                      114048

        Entity contains no Sub-Entities.

        router1/.env> exit

The CLI Message Interface is provided by the Management Swiftlet of a router. For security reasons, it is disabled by default. It can be enabled here:

[SwiftMQ Explorer App, Flow Director]

JMS Message Properties

The following JMS message properties are supported by the CLI Message Interface:

Property

Default

Description

JMS_SWIFTMQ_MGMT_REPLY_QUEUE

Alternative method to JMSReplyTo to specify a reply queue. This is intended for eMail integration. See section below.

JMS_SWIFTMQ_MGMT_SHOW_COMMANDS_IN_RESULT

true

Specifies if the commands should be prompted in the result like `router1/.env> lc router-memory-list/router1`

JMS_SWIFTMQ_MGMT_SUBJECT

The eMail subject for eMail integration. For the result message will be set to `Result for '' `.

Access via JMS

The CLI Message Interface is accessible via basic JMS request/reply. The default input queue is swiftmqmgmt-message-interface. If JMSReplyTo is set in the request, the result will be send to the reply queue as a JMS TextMessage. All JMS message properties are copied from the request into the reply message so any JMS properties (or the JMSCorrelationID) can be used to link request and reply.

There is an example under samples/cli/CLIMessageInterface.java which can be used to send CLI commands stored in a file. Here is an excerpt:

JAVA
        TextMessage msg = session.createTextMessage();
        msg.setJMSReplyTo(replyQueue);
        msg.setText(getFileContent(filename));
        sender.send(msg);
        TextMessage reply = (TextMessage)replyReceiver.receive();
        System.out.println("\nR E S U L T :\n\n"+reply.getText());

Access via eMail

It is possible to integrate the CLI Message Interface and eMail by using the JavaMail Bridge Swiftlet.

BE CAREFUL! If you connect this interface to eMail, be sure that only authorized users can send to this eMail address and define a mail filter for the JavaMail inbound bridge.

Then define 2 bridges, one inbound bridge which sends to the input queue of CLI Message Interface and one outbound bridge which sends the result back to the sender. The connection between both bridges is via the JMS_SWIFTMQ_MGMT_REPLY_QUEUE message property which defines the reply queue for the CLI Message Interface. It must be set to the input queue of the outbound bridge. Property JMS_SWIFTMQ_MGMT_SUBJECTis the eMail subject which will be changed by the CLI Message Interface to Result for '<old subject>'. So it must be translated back and forth.

Example:

XML
      <swiftlet name="xt$javamail">
        <inbound-bridges>
          <inbound-bridge name="admin-in ` enabled="true" mail-host="mx2" 
                          mail-host-account-name="tst" mail-host-account-password="xxxxxx"
                          mail-host-port="143" protocol="imap" retrieveinterval="30000" 
                          target-name="swiftmqmgmt-message-interface">
            <default-properties>
              <default-property name="JMS_SWIFTMQ_MGMT_REPLY_QUEUE" value="admin-out@router1"/>
              <default-property name="JMS_SWIFTMQ_MGMT_SHOW_COMMANDS_IN_RESULT" value="true"/>
            </default-properties>
            <javamail-properties/>
            <mail-filter-definition mail-filter-reject-from-address="noreply@swiftmq.com">
              <mail-filters>
                <mail-filter name="01" filter-type="header" reject-on-match="false" 
                             rejection-message="No, Sir!" return-to-sender="true">
                  <filter-properties>
                    <filter-property name="from" value= `.*@iit.de"/>
                  </filter-properties>
                </mail-filter>
              </mail-filters>
            </mail-filter-definition>
            <property-translations>
              <property-translation name="1" message-property="FROM"/>
              <property-translation name="2" mail-header="subject" message-property="JMS_SWIFTMQ_MGMT_SUBJECT"/>
            </property-translations>
          </inbound-bridge>
        </inbound-bridges>
        <outbound-bridges>
          <outbound-bridge name="admin-out" enabled="true" smtp-host="mx2" source-name="admin-out">
            <default-headers>
              <default-header name="from" value="mgmt@router1"/>
            </default-headers>
            <header-translations>
              <header-translation name="1" mail-header="to" message-property="FROM"/>
              <header-translation name="2" mail-header="subject" message-property="JMS_SWIFTMQ_MGMT_SUBJECT"/>
            </header-translations>
            <javamail-properties/>
          </outbound-bridge>
        </outbound-bridges>
      </swiftlet>

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.