This is part of a series of small blog posts which will cover some of the smaller, perhaps less likely to be noticed, features of IBM MQ. Read other posts in this series.
I'm a big fan of MQ SERVICE objects, use them a lot:
to name but a few.
I like them because of the simplicity of ensuring necessary applications are always running whenever the queue manager is running. Just use CONTROL(QMGR) and the rest just happens.
I have written about the use of SERVICE object before, as shown by the links above.
In this post I want to write about service status, that is the command DISPLAY SVSTATUS, and a clever little trick that MQ does to make this work.
Now specifically, this is about SERVTYPE(SERVER) objects and does not apply to SERVTYPE(COMMAND) objects. DISPLAY SVSTATUS does not apply to SERVTYPE(COMMAND) objects.
So, when you start up a program using the command START SERVICE(service-name), the queue manager remembers the PID of the started process. This is in fact externalised for you to see when you issue DISPLAY SVSTATUS(service-name)
AMQ8632I: Display service status details.
SERVICE(MQGEM.TRIGGER.MONITOR) STATUS(RUNNING)
PID(4064) SERVTYPE(SERVER)
STARTDA(2026-06-12) STARTTI(20.52.13)
CONTROL(QMGR) STARTCMD(E:\mqm9450\bin64/runmqtrm)
STARTARG(-m MQG1 -q MQGEM.INITQ) STOPCMD(E:\mqm9450\bin64/amqsstop)
STOPARG(-m MQG1 -p 4064) DESCR(Trigger Monitor Service)
STDOUT( ) STDERR( )
And it is also available for you to use in your STOPCMD arguments with the +MQ_SERVER_PID+ insert.
ALTER SERVICE(service-name) +
STOPCMD('+MQ_INSTALL_PATH+bin64\amqsstop') +
STOPARG('-m +QMNAME+ -p +MQ_SERVER_PID+')
The above example is from this post.
Knowing that the DISPLAY SVSTATUS does this, means that you can tell whether the executable is running, even if it does not have a connection to the queue manager that would show up in DISPLAY CONN. This is useful if you are attempting to update the executable and therefore need to ensure that it is not currently running.
As a test of this, try running something that isn't even an MQ program as an MQ SERVICE object with SERVTYPE(SERVER) and then run DISPLAY SVSTATUS on it, and then terminate the program and run DISPLAY SVSTATUS again.
So, for actual MQ applications that are started in this way, even if it hasn't connected to the queue manager, or has disconnected but hasn't shut down, your queue manager knows about it because it remembers the PID.
This is just one more neat thing about using SERVICE objects.
#Little-Gem
#IBMMQ
#IBMChampion