Hello,
I am an Administrator and to ease of my life, I am trying to write an utility which will give the broker client information (name and size) using the following code.
But when executed, I am getting null values for both client name and size. Can anyone please help in finding the cause of not getting Broker client name and size. Being a non developer, I am not able to pinpoint the exact issue.
Need expert help. Thank you.
Code:
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String broker_host = IDataUtil.getString( pipelineCursor, “broker_host” );
String broker_name = IDataUtil.getString( pipelineCursor, “broker_name” );
//String clientID = IDataUtil.getString( pipelineCursor, “clientID” );
pipelineCursor.destroy();
String client_group = "admin";
BrokerAdminClient client;
BrokerEvent event;
String[] str=null;
String message="";
String[] tmp_size= null;
String[] size= null;
String[] ClientID= null;
int j=0;
long queueDim = 0;
try {
client= new BrokerAdminClient(broker_host, broker_name, null, client_group ,"Broker Description" ,null);
str= client.getClientIds();
tmp_size= new String[str.length];
size= new String[str.length];
ClientID= new String[str.length];
for (int i=0;i<str.length;i++){
try {
event = client.getClientStatsById(str[i]);
queueDim = event.getLongField("queueByteSize");
size[i] = String.valueOf((event.getLongField("queueByteSize")/1048576));
if (queueDim > 1050000)
{
tmp_size[j] = size[i];
ClientID[j] = str[i];
j++;
}
}catch (BrokerException ex) {
System.out.println("error on destroying client"+ex);
client.destroy();
}
}
client.destroy();
}catch(Exception e){
System.out.println(e);
}
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “message”, message );
IDataUtil.put( pipelineCursor_1, “ClientID”, ClientID );
IDataUtil.put( pipelineCursor_1, “size_MB”, tmp_size);
pipelineCursor_1.destroy();