Use the tibemsadmin utility provided with your EMS installation. For details on the options available for tibemsadmin, refer to the EMS User's Guide under the section 'Using the EMS Administration Tool'.
First, write a simple tibemsadmin script. For example, create a file named 'tibemsadmin.txt' with the following line:
show queue Subject.BookData
Then use the tibemsadmin's -script option to run it. For example..
tibemsadmin.exe -server "tcp://localhost:7222" -user admin -password admin -script tibemsadmin.txt
The resulting output will look like the following:
TIBCO Enterprise Message Service Administration Tool.
Copyright 2003-2019 by TIBCO Software Inc.
All rights reserved.
Version 8.5.1 V4 9/12/2019
Connected to: tcp://localhost:7222
Command: show queue Subject.BookData
Queue: Subject.BookData
Type: static
Properties: *prefetch=5,*store=$sys.nonfailsafe
JNDI Names: <none>
Bridges: <none>
Receivers: 0
Pending Msgs: 568, (0 persistent)
Delivered Msgs: 0
Pending Msgs Size: 64.3 Kb, (0.0 Kb persistent)
Here, we can see Pending Msgs count for the 'Subject.BookData' queue is 568. To log the pending message count at regular intervals to a file, use a script like the following:
Windows (*.bat):
@echo off
cd %EMS_HOME%\bin
:loop
:: Log the current time
echo %date% %time% >> pending-msgs.log
:: Log the pending message count
tibemsadmin.exe -server "tcp://localhost:7222" -user admin -password admin -script tibemsadmin.txt | findstr /R /C:"\<Pending Msgs:" >> pending-msgs.log
:: Collection interval in seconds
timeout /t 5
goto loop
Linux (*.sh):
#!/bin/bash
cd $EMS_HOME/bin
while true; do date >> pending-msgs.log ; ./tibemsadmin -server "tcp://localhost:7222" -user admin -password admin -script tibemsadmin.txt | grep Pending\ Msgs\: >> pending-msgs.log ; sleep 5; done
This will log the pending message count with a current timestamp value every 5 seconds to the file named 'pending-msgs.log'. This log may be used to identify surges and irregularities in EMS traffic relating to this queue, which can help in troubleshooting issues with your BusinessEvents application.
NOTE: If the EMS server requires a secure (SSL) connection, the tibemsadmin syntax would instead look like..
Windows:
tibemsadmin.exe -server "ssl://localhost:7243" -user admin -password admin -ssl_trusted ..\samples\certs\server_root.cert.pem -ssl_identity ..\samples\certs\client_identity.p12 -ssl_issuer ..\samples\certs\client_root.cert.pem -ssl_password password -ssl_hostname server
Linux:
./tibemsadmin -server ssl://127.0.1.1:7243 -user admin -password admin -ssl_trusted ../samples/certs/server_root.cert.pem -ssl_identity ../samples/certs/client_identity.p12 -ssl_password password -ssl_hostname server
..where the client & server certificates are specified in the above tibemsadmin command parameters.