Jigar Thakkar
Jigar Thakkar

Reputation: 1

Getting TIBCO EMS Queue details from java

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.

Upvotes: 0

Views: 4662

Answers (2)

GunWanderer
GunWanderer

Reputation: 324

Props to @nochum. I converted the Java code into .Net C#.

private void TibcoEmsAdmin(bool useTopic)
{
    long pendingMessages,
        pendingSize,
        inMsgRate,
        inByteRate,
        outMsgRate,
        outByteRate;

    TIBCO.EMS.ADMIN.Admin emsAdmin = new TIBCO.EMS.ADMIN.Admin(
        _server,
        _userName,
        _userCredential
    );

    if (useTopic)
    {
        //Use topic
        TIBCO.EMS.ADMIN.DestinationInfo di = emsAdmin.GetQueue(_loggingQueueName);
        TIBCO.EMS.ADMIN.StatData iStats = di.InboundStatistics;
        TIBCO.EMS.ADMIN.StatData oStats = di.OutboundStatistics;
        pendingMessages = di.PendingMessageCount;
        pendingSize = di.PendingMessageSize;
        inMsgRate = iStats.MessageRate;
        inByteRate = iStats.ByteRate;
        outMsgRate = oStats.MessageRate;
        outByteRate = oStats.ByteRate;
    }
    else
    {
        //Use queue
        TIBCO.EMS.ADMIN.QueueInfo di = emsAdmin.GetQueue(_loggingQueueName);
        TIBCO.EMS.ADMIN.StatData iStats = di.InboundStatistics;
        TIBCO.EMS.ADMIN.StatData oStats = di.OutboundStatistics;
        pendingMessages = di.PendingMessageCount;
        pendingSize = di.PendingMessageSize;
        inMsgRate = iStats.MessageRate;
        inByteRate = iStats.ByteRate;
        outMsgRate = oStats.MessageRate;
        outByteRate = oStats.ByteRate;
    }

    //application logic here
}

Upvotes: 0

nochum
nochum

Reputation: 795

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++;
}

Upvotes: 3

Related Questions