How to log an EMS queue's pending message count to a file at regular intervals to assist with BusinessEvents applciation troubleshooting

How to log an EMS queue's pending message count to a file at regular intervals to assist with BusinessEvents applciation troubleshooting

book

Article ID: KB0072609

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition N/A

Description

I have an EMS queue to which my BusinessEvents application is subscribed. I would like to get the pending message count at regular intervals, for example every 5 seconds. How can I log this information to a file so that I can analyze how many pending messages remained at a particular point in time? This could help troubleshoot issues in my BusinessEvents application that may relate to EMS message processing performance.
 

Issue/Introduction

Explains how to run the tibemsadmin utility in a loop, in order to log an EMS queue's pending message count to a file. This can help troubleshoot issues in your BusinessEvents application that may relate to EMS message processing performance.

Environment

All Supported Environments

Resolution

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.