0
votes

Am working on a POC: 1. to get list of queues on a given TIBCO EMS server from my Java application. 2. From the list of queues, on clicking a queue name, pending messages on that queue should be displayed (like message name, message property, etc.).

Was able to achieve point 1 above using TibJmsAdmin. But not sure how to achieve point 2. Have used TibjmsConnectionFactory in the past to produce and consume messages on a Topic/Queue. But how do i get info of pending messages on a particular queue.

Thanks in advance.

1

1 Answers

2
votes

If you are looking for statistics for the queue or topic, try this:

TibjmsAdmin admin = new TibjmsAdmin(serverUrl,username,password);

DestinationInfo di = null;
if (useTopic) {
    di = admin.getTopic(destName);
} else {
    di = admin.getQueue(destName);
}

StatData iStats = di.getInboundStatistics();
StatData oStats = di.getOutboundStatistics();

long pendingMessages = di.getPendingMessageCount();
long pendingSize = di.getPendingMessageSize();
long inMsgRate = iStats.getMessageRate();
long inByteRate = iStats.getByteRate();
long outMsgRate = oStats.getMessageRate();
long outByteRate = oStats.getByteRate();

If you are looking to browse the messages in the queue without consuming them try using a QueueBrowser:

QueueBrowser browser = session.createBrowser(queue);
Enumeration msgs = browser.getEnumeration();

int browseCount=0;

while (msgs.hasMoreElements())
{
    message = (javax.jms.Message)msgs.nextElement();
    System.err.println("Browsed message: number="+message.getIntProperty("msg_num"));
    browseCount++;
}