Use a server service object
This example shows how to define, use, and alter, a server service object to start a trigger monitor.
- A server service object is defined, using the DEFINE SERVICE MQSC command:
DEFINE SERVICE(S1) + CONTROL(QMGR) + SERVTYPE(SERVER) + STARTCMD('+MQ_INSTALL_PATH+bin/runmqtrm') + STARTARG('-m +QMNAME+ -q ACCOUNTS.INITIATION.QUEUE') + STOPCMD('+MQ_INSTALL_PATH+bin/amqsstop') + STOPARG('-m +QMNAME+ -p +MQ_SERVER_PID+')
Where:- +MQ_INSTALL_PATH+ is a token representing the installation directory.
- +QMNAME+ is a token representing the name of the queue manager.
- ACCOUNTS.INITIATION.QUEUE is the initiation queue.
- amqsstop is a sample program provided with IBM MQ which requests the queue manager to break all connections for the process ID. amqsstop generates PCF commands, therefore the command server must be running.
- +MQ_SERVER_PID+ is a token representing the process ID passed to the stop program.
See Replaceable inserts on service definitions for a list of the common tokens.
- An instance of the server service object will execute when the queue manager is next started.
However, we will start an instance of the server service object immediately with the START
SERVICE MQSC command:
START SERVICE(S1)
- The status of the server service process is displayed, using the DISPLAY
SVSTATUS MQSC command:
DISPLAY SVSTATUS(S1)
- This example now shows how to alter the server service object and have the
updates picked up by manually restarting the server service process. The server service object is
altered so that the initiation queue is specified as JUPITER.INITIATION.QUEUE. The
ALTER SERVICE MQSC command is used:
ALTER SERVICE(S1) + STARTARG('-m +QMNAME+ -q JUPITER.INITIATION.QUEUE')
Note: A running service will not pick up any updates to its service definition until it is restarted. - The server service process is restarted so that the alteration is picked up, using the
STOP SERVICE and START SERVICE MQSC commands:
STOP SERVICE(S1)
Followed by:START SERVICE(S1)
The server service process is restarted and picks up the alterations made in 4. Note: The MQSC command, STOP SERVICE, can only be used if a STOPCMD argument is specified in the service definition.
Parent topic: Examples of using service objects
Related information