Installing SwiftMQ Universal Router as a Windows Service

Introduction

SwiftMQ 4.7.0 onwards contains "JavaSerice.exe" and "installService.bat" as part of the Windows distribution. Both files are located within the "scripts/win32" directory. "JavaService.exe" works fine with Sun's JVMs, however, it doesn't seems to work with IBM JVMs.

Preparations

The "installService.bat" uses the following environment variables and values. If you use different values, you must edit "installService.bat".

Environment Variable Meaning Default Value
JAVA_HOME JDK Home Directory Not set
SWIFTMQ_SERVICENAME Name of the SwiftMQ Service SwiftMQ
SWIFTMQ_ROUTERNAME Name of the SwiftMQ Universal Router router1
SWIFTMQ_WD Working Directory Current directory (%CD%)
SWIFTMQ_JARS JAR Files of the SwiftMQ router All JAR files in ../../jars
SWIFTMQ_CONFIG_FILE The router's configuration file. ../../config/%SWIFTMQ_ROUTERNAME%/routerconfig.xml
STDOUT Service 'stdout' ../../log/%SWIFTMQ_ROUTERNAME%/service-stdout.log
STDERR Service 'stderr' ../../log/%SWIFTMQ_ROUTERNAME%/service-stderr.log

Installation / Removal

To install SwiftMQ as a service, change into the "scripts/win32" directory and type:

      installService install

The service is not started per default. To start it automatically you must change the startup mode of the service via the Control Panel.

To remove an installed SwiftMQ service type:

      installService remove

Stopping a running SwiftMQ Service

It is very important to ensure that the SwiftMQ router runs through the shutdown hook! Therefore, CLI is defined as a "stop" class. Here is the resp. snippet from the command line of "JavaService.exe":

      -stop com.swiftmq.admin.cli.CLI
            -params smqp://localhost:4001 plainsocket@%SWIFTMQ_ROUTERNAME% %SWIFTMQ_WD%/shutdown.cli

As you see, the default JMS listener on port 4001 is used as well as the default connection factory "plainsocket" of the resp. router. To shutdown the router, "shutdown.cli" is used.

If you use other values, you must change the parameters in "installService.bat". Note that you must change the router name in shutdown.cli as well if you use another router name!

If you change the default values, please take the time to test whether the SwiftMQ router is stopped orderly by viewing the STDOUT log file. It must contains the output of the shutdown sequence like this:

Example:

      Booting SwiftMQ 4.7.0 Production ...
      ... startup: Trace Swiftlet
      ... startup: Log Swiftlet
      ... startup: Authentication Swiftlet
      ... startup: Threadpool Swiftlet
      ... startup: Timer Swiftlet
      ... startup: Network Swiftlet
      ... startup: Store Swiftlet
      ... startup: Queue Manager Swiftlet
      ... startup: Topic Manager Swiftlet
      ... startup: Management Swiftlet
      ... startup: XA Resource Manager Swiftlet
      ... startup: Routing Swiftlet (Single Connection)
      ... startup: JNDI Swiftlet
      ... startup: JMS Swiftlet
      ... startup: Deploy Swiftlet
      ... startup: JMS Application Container Swiftlet
      ... startup: Scheduler Swiftlet
      SwiftMQ 4.7.0 Production is ready.
      Router 'router1' is available for administration.

      Router Halt in 10 Seconds.

      Shutdown SwiftMQ 4.7.0 Production ...
      ... shutdown: Scheduler Swiftlet
      ... shutdown: JMS Application Container Swiftlet
      ... shutdown: Deploy Swiftlet
      ... shutdown: JMS Swiftlet
      ... shutdown: JNDI Swiftlet
      ... shutdown: Routing Swiftlet (Single Connection)
      ... shutdown: XA Resource Manager Swiftlet
      ... shutdown: Management Swiftlet
      ... shutdown: Topic Manager Swiftlet
      ... shutdown: Queue Manager Swiftlet
      ... shutdown: Store Swiftlet
      ... shutdown: Network Swiftlet
      ... shutdown: Timer Swiftlet
      ... shutdown: Threadpool Swiftlet
      ... shutdown: Authentication Swiftlet
      ... shutdown: Log Swiftlet
      ... shutdown: Trace Swiftlet
      Shutdown SwiftMQ 4.7.0 Production DONE.