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 will not need to use the Message Queue Broker utility (imqbrokerd) unless you want to start an additional broker.
A system can have no more than one broker running as a Windows service. The Windows 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 option 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.
The procedure for reconfiguring a broker installed as a Windows service is as follows:
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
imqsvcadmin remove
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 the 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,
-javahome c:\\j2sdk1.4.0
To determine the startup options for the broker service, use the imqsvcadmin query command, as shown in Example 3–1.
|
If you get an error when you try to start a broker as a Windows service, you can view error events that were logged: