Mani,
I wrote this java service to run in the IS to monitor queue length. It returns any queues and their length if the length is greater than a threshold passed to the service. I send out an email when a queue has passed the threshold. You can change it to return all of the client queues.
I pass brokerHost, brokerName, and threshold as input
and return brokerHost, brokerName, and threshold and a document list that includes clientId, queueLength and queueByteSize
import java.io.*
import com.activesw.API.client.*
public static final void CheckQueueLength(IDataPipeline) throws ServiceException
{
IDataHashCursor pipelineCursor = pipeline.getHashCursor();
pipelineCursor.first( “brokerHost” );
String brokerHost = (String) pipelineCursor.getValue();
pipelineCursor.first( “brokerName” );
String brokerName = (String) pipelineCursor.getValue();
pipelineCursor.first( “threshold” );
String threshold = (String) pipelineCursor.getValue();
Long Long_threshold = new Long(threshold);
String clientGroup = “admin”;
BrokerEvent clientEvent;
String clientIds;
try
{
BrokerAdminClient brokerClient = new BrokerAdminClient(brokerHost, brokerName, null, clientGroup, “Broker Stats Monitor”, null);
clientIds = brokerClient.getClientIds();
try
{
// Count the number of clients with a queuelenght > than the threshold
int clientCount = 0;
for (int i = 0; i < clientIds.length; i++)
{
try
{
clientEvent = brokerClient.getClientStatsById(clientIds[i]);
Long l_queueLength = new Long(clientEvent.getLongField("queueLength"));
int isGreater = l_queueLength.compareTo(Long_threshold);
if (isGreater > 0 )
{
clientCount++;
}
}
catch (BrokerException ex1)
{
brokerClient.destroy();
return;
}
}
// clientGroupStats
IData clientGroupStats[] = new IData[clientCount];
int clientIndex = 0;
for (int i = 0; i < clientIds.length; i++)
{
try
{
clientEvent = brokerClient.getClientStatsById(clientIds[i]);
Long l_queueLength = new Long(clientEvent.getLongField("queueLength"));
int isGreater = l_queueLength.compareTo(Long_threshold);
if (isGreater > 0 )
{
clientGroupStats[clientIndex] = IDataFactory.create();
IDataCursor clientGroupStatsCursor = clientGroupStats[clientIndex].getCursor();
String s_queueLength = l_queueLength.toString();
Long l_queueByteSize = new Long(clientEvent.getLongField("queueByteSize"));
String s_queueByteSize = l_queueByteSize.toString();
clientGroupStatsCursor.last();
clientGroupStatsCursor.insertAfter("clientId", clientIds[i] );
clientGroupStatsCursor.insertAfter("queueLength", s_queueLength);
clientGroupStatsCursor.insertAfter("queueByteSize", s_queueByteSize);
clientIndex++;
clientGroupStatsCursor.destroy();
}
}
catch (BrokerException ex1)
{
brokerClient.destroy();
return;
}
}
// clientGroupsCursor.insertAfter("Stats", clientGroupStats);
pipelineCursor.last();
pipelineCursor.insertAfter("clientQueueLength", clientGroupStats);
pipelineCursor.destroy();
try
{
brokerClient.destroy();
}
catch (BrokerException ex)
{
//log("error on destroy of BrokerServerClient "+ex);
return;
}
}
catch (BrokerException ex1)
{
//log("broker excception on client statsget\n"+ex1);
brokerClient.destroy();
return;
}
}
catch (BrokerException ex2)
{
//log(“broker excception on client statsget\n”+ex2);
return;
}
}
Thanks,
Steve