I am writing a Java class to browse a Tibco EMS JMS server and show all queues. I'm able to connect without issues and browse specific queues but I am looking for a way to return a list of all queues (with queue depth if possible). I'm not if there is a specific EMS API to use so I am using standard JMS.
I've tried the following code to do a reverse JNDI lookup but it is failing.
NamingEnumeration<?> queues = context.list("");
List<String> availableQueuesNames = new ArrayList<String>();
while (queues.hasMoreElements()) {
NameClassPair element = (NameClassPair) queues.nextElement();
availableQueuesNames.add(element.getName());
}
Which throws this error:
javax.naming.OperationNotSupportedException: Not supported
at com.tibco.tibjms.naming.TibjmsContext.list(TibjmsContext.java:1018)
at com.tibco.tibjms.naming.TibjmsContext.list(TibjmsContext.java:484)
at javax.naming.InitialContext.list(Unknown Source)
I did some digging and it seems Tibco EMS does not support looking into the JNDI like this. Is there another way to accomplish this?
Using the tibjmsServerAdministrator.java same class provided with Tibco as a guide (and the addAdmin() method), I was able to write code to list all queues:
Map<String, TibjmsAdmin> map = new HashMap<String, TibjmsAdmin>();
addAdmin(txtServer.getText(), txtUser.getText(), txtPassword.getText(), map);
_admin = new TibjmsAdmin[map.size()];
map.values().toArray(_admin);
QueueInfo[] info = _admin[0].getQueues(null);
for (int i = 0; i < info.length; i++) {
String queueName = info[i].getName();
if (!queueName.startsWith("$") && !queueName.startsWith(">")) {
queues.add(queueName + ", 0");
}
}