Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get number of messages on a queue 1

Status
Not open for further replies.

jbabad

Programmer
May 28, 2002
5
GB
Hi,

Does anyone know how to get the number
of messages on a queue?
There are some utility program that SeeBeyond
provide, but I'm looking to it with some sort
of API from within a Java program.
I don't really want to have to exec a program
from within my Java code.

Cheers.
 
I believe the e*Gate monitor has an iq manager that allows you to view the # of messages and the contents of the messages. Its part of the e*Gate Monitor GUI.
 
hi,

you can de-compile the stcqviewer class (you see that seebeyond uses the topic STCMS.Control to retrieve the number of messages from a specific queue manager).
Now, you should be able to implement your own QueueBrowser (which is missing in the stc api).

regards,

reinhold

here comes an example ...

private void init() throws JMSException {
Properties properties = new Properties();
properties.put("com.seebeyond.jms.sockets.RetryCount", "0");
properties.put("com.seebeyond.jms.sockets.RetryInterval", "0");

topicConnectionFactory = new STCTopicConnectionFactory(properties);

((STCTopicConnectionFactory)topicConnectionFactory).setHost(getHost());
((STCTopicConnectionFactory)topicConnectionFactory).setPort(getPort());

topicConnection = topicConnectionFactory.createTopicConnection();
topicConnection.start();

topicSession = topicConnection.createTopicSession(false, 2);
Topic controlTopic = topicSession.createTopic("STCMS.Control");
topicPublisher = topicSession.createPublisher(controlTopic);
topicPublisher.setDeliveryMode(1);
TemporaryTopic tempReplyTopic = topicSession.createTemporaryTopic();
topicSubscriber = topicSession.createSubscriber(tempReplyTopic);
message = topicSession.createMessage();
message.setJMSReplyTo(tempReplyTopic);
message.setJMSDeliveryMode(1);
}

public void update() throws JMSException {
message.setIntProperty("Message.Type", 9); // get topic statistics
message.setStringProperty("QueueManager.TopicName", getTopicName());
topicPublisher.publish(message);
replyMessage = topicSubscriber.receive(5000L);

if(replyMessage == null) {
/** throw exception */
return ;
}
if(!replyMessage.getBooleanProperty("Success.Code")) {
/** throw exception */
return ;
} else {
// replyMessage.getStringProperty("TopicStats.TopicName");
setFirstSequence(replyMessage.getLongProperty("TopicStats.FirstSequence"));
setLastSequence(replyMessage.getLongProperty("TopicStats.LastSequence"));
setLowestSubscriberSequence(replyMessage.getLongProperty("TopicStats.LowestSubcriberSequence")); // possibly change this to ...Subscriber...
setHighestSubscriberSequence(replyMessage.getLongProperty("TopicStats.HighestSubscriberSequence"));
setFirstEnqueue(replyMessage.getLongProperty("TopicStats.FirstEnqueue"));
setLastEnqueue(replyMessage.getLongProperty("TopicStats.LastEnqueue"));
setTotalSubscribers(replyMessage.getLongProperty("TopicStats.TotalSubscribers"));
setCurrentSubscribers(replyMessage.getLongProperty("TopicStats.CurrentSubscribers"));
setMessageCount(replyMessage.getLongProperty("TopicStats.MessageCount"));
}
}
 
Hi,

Thanks, that was useful.

Cheers,
Joseph.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top