You can start a broker either interactively, using the Message Queue command line utilities or the Windows Start menu, or by arranging for it to start automatically at system startup. The following sections describe how.
You can start a broker interactively from the command line, using the Broker utility (imqbrokerd). (Alternatively, on Windows, you can start a broker from the Start menu.) You cannot use the Administration Console (imqadmin) or the Command utility (imqcmd) to start a broker; the broker must already be running before you can use these tools.
On the Solaris and Linux platforms, a broker instance must always be started by the same user who initially started it. Each broker instance has its own set of configuration properties and file-based message store. When the broker instance first starts, Message Queue uses the user’s file creation mode mask (umask ) to set permissions on directories containing the configuration information and persistent data for that broker instance.
A broker instance has the instance name imqbroker by default. To start a broker from the command line with this name and the default configuration, simply use the command
This starts a broker instance named imqbroker on the local machine, with the Port Mapper at the default port of 7676 (see Port Mapper).
To specify an instance name other than the default, use the- name option to the imqbrokerd command. The following command starts a broker with the instance name myBroker:
imqbrokerd -name myBroker
Other options are available on the imqbrokerd command line to control various aspects of the broker’s operation. The following example uses the- tty option to send errors and warnings to the command window (standard output):
imqbrokerd -name myBroker -tty
You can also use the -D option on the command line to override the values of properties specified in the broker’s instance configuration file (config.properties). This example sets the imq.jms.max_threads property, raising the maximum number of threads available to the jms connection service to 2000:
imqbrokerd -name myBroker -Dimq.jms.max_threads=2000
See Broker Utility for complete information on the syntax, subcommands, and options of the imqbrokerd command. For a quick summary of this information, enter the command
If you have a Sun Java System Message Queue Platform Edition license, you can use the imqbrokerd command’s- license option to activate a trial Enterprise Edition license, allowing you to try Enterprise Edition features for 90 days. Specify try as the license name:
imqbrokerd -license try
You must use this option each time you start a broker; otherwise the broker will default to the standard Platform Edition license.
Instead of starting a broker explicitly from the command line, you can set it up to start automatically at system startup. How you do this depends on the platform (Solaris, Linux, or Windows) on which you are running the broker.
On Solaris and Linux systems, scripts that enable automatic startup are placed in the /etc/rc* directory tree during Message Queue installation. To enable the use of these scripts, you must edit the configuration file /etc/imq/imqbrokerd.conf (Solaris) or /etc/opt/sun/mq/imqbrokerd.conf (Linux) as follows:
To set startup command line arguments for the broker, specify one or more values for the ARGS property.
To start a broker automatically at Windows system startup, you must define the broker as a Windows service. The broker will then start at system startup time and run in the background until system shutdown. Consequently, you do not use the imqbrokerd command to start the broker unless you want to start an additional instance.
A system can have no more than one broker running as a Windows service. Task Manager lists such a broker as two executable processes:
The native Windows service wrapper, imqbrokersvc.exe
The Java runtime that is running the broker
You can install a broker as a service when you install Message Queue on a Windows system. After installation, you can use the Service Administrator utility ( imqsvcadmin) to perform the following operations:
Add a broker as a Windows service
Determine the startup options for the broker service
Remove a broker that is running as a Windows service
To pass startup options to the broker, use the -args argument to the imqsvcadmin command. This works the same way as the imqbrokerd command’s -D option, as described under Starting Brokers. Use the Command utility (imqcmd) to control broker operations as usual.
See Service Administrator Utility for complete information on the syntax, subcommands, and options of the imqsvcadmin command.
Stop the service.
From the Settings submenu of the Windows Start menu, choose Control Panel.
Open the Administrative Tools control panel.
Run the Services tool by selecting its icon and choosing Open from the File menu or the pop-up context menu, or simply by double-clicking the icon.
Under Services (Local), select the Message Queue Broker service and choose Properties from the Action menu.
Alternatively, you can right-click on Message Queue Broker and choose Properties from the pop-up context menu, or simply double-click on Message Queue Broker. In either case, the Message Queue Broker Properties dialog box will appear.
Under the General tab in the Properties dialog, click Stop to stop the broker service.
Remove the service.
On the command line, enter the command
Reinstall the service, specifying different broker startup options with the -args option or different Java version arguments with the - vmargs option.
For example, to change the service’s host name and port number to broker1 and 7878, you could use the command
imqsvcadmin install -args "-name broker1 -port 7878"
You can use either imqsvcadmin command’s -javahome or -jrehome option to specify the location of an alternative Java runtime. (You can also specify these options in the Start Parameters field under the General tab in the service’s Properties dialog window.)
The Start Parameters field treats the backslash character (\\ ) as an escape character, so you must type it twice when using it as a path delimiter: for example,
To determine the startup options for the broker service, use the query option to the imqsvcadmin command, as shown in Example 3–1.