Skip to main content

Summary This article explains how the length of a workqueue can be queried at runtime
Article Number 34226
Environment Orbix 6.3.5 Java All Supported Operating Systems
Question/Problem Description How to programatically query the length of the automatic workqueues of an Orbix process?
Clarifying Information The length of the AutomaticWorkQueue of an Orbix process can be queried from the Orbix Management Service which needs to be configured and started in your Orbix domain.

Error Message
Defect/Enhancement Number
Cause
Resolution Below is the sample code for querying the length of the AutomaticWorkQueue. A compiled version of the code below is attached to this article.
The object name for a workqueue can be retrieved from the Orbix Management Console.


import java.io.*;
import java.util.*;
import org.omg.CORBA.*;
import com.iona.management.JMXRemote.*;
import com.iona.management.IT_ManagementService.*;

/*

This is an example on how to query the length of an automatic workqueue in Orbix.

This example makes use of the Management Service, so the Orbix process will need
to  have management enabled and the Orbix Management Service needs to be configured
and running in your Orbix domain.

You can easily enable management in your orbix process by starting your process by
passing the following ORb argument to your Orbix process

-ORBplugins:orb:is_managed true -ORBplugins:it_mgmt:managed_server_id:name my_managed_server

The length of the workqueue for the process can be queried with this client by running

java WorkQueueClient "DefaultDomain:type=AutoWorkqueue,orb=_it_orb_id_1,name=Workqueue_1,cascaded=_it_orb_id_1"

*/

public class WorkQueueClient
{

    public static void main (String args[])
    {
        ORB orb = null;
        String workqueueObjectName = "";
        String attribute = "QueueLength";

        if (args.length != 1) {
            System.out.println("Please pass the object name of the Workqueue!");
        } else {
            workqueueObjectName = args[0];
        }

        ManagementService sm_managementService = null;

        try  {
            java.util.Properties props = System.getProperties();
            props.put("org.omg.CORBA.ORBClass", "com.iona.corba.art.artimpl.ORBImpl");
            props.put("org.omg.CORBA.ORBSingletonClass", "com.iona.corba.art.artimpl.ORBSingleton");

            orb = ORB.init(args, props);
            org.omg.CORBA.Object managementServiceObj = orb.resolve_initial_references("IT_MgmtServiceUser");
            sm_managementService = ManagementServiceHelper.narrow(managementServiceObj);
            com.iona.management.IT_ManagementService.Information info = sm_managementService.server_information();

            boolean isRegistered = info.is_registered(workqueueObjectName);

            if (isRegistered) {
                NameAttrValue attr=null;
                attr = info.get_attribute(workqueueObjectName, attribute);
                System.out.println(attr.name " = " attr.value.a_long());
            } else {
                System.out.println("\\n\\nFollowing object name is not registered:\\n" workqueueObjectName);
            }
        }
        catch (Exception ex) {
            System.err.println("Exception: " ex.getMessage());
            ex.printStackTrace(System.err);
        }

        finally {
            if (orb != null) {
                try {
                    orb.shutdown(true);
                } catch (Exception ex)  {  }
            }
        }
    }
}
Workaround
Notes

For further information on using Orbix Management please see:
Orbix Management User Guide
Orbix Management Programmers Guide

available at:

http://supportline.microfocus.com/Documentation/books/Orbix/635/management user guide.pdf

http://supportline.microfocus.com/Documentation/books/Orbix/635/management programmers guide.pdf

Attachment

Created date: 24 August 2012
Last Modified: 12 February 2013
Last Published: 24 August 2012
First Published date: 24 August 2012

#KnowledgeDocs
#Orbix