Finding Broker queue length

Hello All,

Is there any std build-in service available for the fetching the broker queue length?

Also just want know,is there any way to see the source code of the inbuild java service in webmMethods?

Thanks,
Mani

import COM.activesw.API.client.*;
public class QueueCheck
{
public static void main(String args)
{
String broker_host = args[0];
String broker_name = args[1];
String client_group = args[2];
String client_state_name = args[3];
BrokerClient bc;
BrokerEvent e, evt;
BrokerConnectionDescriptor bcd;
boolean shared = true;
long sq_no;
int i = 0;
int len = 0;
//create a broker connection descriptor
bcd = new BrokerConnectionDescriptor();
bcd.setStateShare(shared);
bcd.setConnectionShare(true);
//create a broker client
try {
bc = BrokerClient.newOrReconnect(broker_host,broker_name,client_state_name,
client_group,“QueueCheck”,bcd);
System.out.println(“Test Brokerclient connected”);
} catch(BrokerException ex) {
System.out.println(“Error on creating a broker client\n” + ex);
return;
}//create broker client

//get the que Length
try {
    len = bc.getQueueLength();
    System.out.println("Number of events in the queue: " + len);
} catch(BrokerException ex) {
 System.out.println(ex);
}//get que length

//retreive the events
e = new BrokerEvent[len];
evt = new BrokerEvent[len];
while(i<len)
  {
      try {
            e = bc.getEvents(1, -1, 6000);
            evt[i] = e[0];
            System.out.println("Received " + evt[i].getTypeName() + " event");
            System.out.println("" + evt[i]);
            i++;
      } catch(BrokerException ex) {
           System.out.println("getEvents() not successful...\n" + ex);
           return;
      }//try
  }//while

//disconnect the brokerClient
try {
       bc.disconnect();
       System.out.println("Disconnected TestSubscriber brokerClient");
} catch(BrokerException ex) {
     System.out.println("Error on destroying the broker client\n" + ex);
     return;
}//try

}
}

Hi Malani,

Can we use this code as Java Service.
If yes
which package do i need to import in shared tab?
Do i need to create broker client in code?
What will be the input if i am using this code as java service.

Actually i tried using this code as java service, but no luck :frowning:

Your quick response will be highly appreciated.

Regards,
Mangat Rai

Yes this can be used as java service.
You need to import COM.activesw.API.client.* package

Can any one please let me know wthether broker queue length is same as broker queue depth.