Browsing message in Queue using JMS and JMQ
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bipin_Jha
Posted On:   Tuesday, May 22, 2001 05:44 AM

How do I use QueueBrowser? When I am sending and receiving messages simultaneously and then browsing for messages in Queue, it shows. When I am only trying to browse it doesn't show anything. I am getting the enumeration from queueBrowser. The code is given below. com.sun.messaging.QueueConnectionFactory qcf = new com.sun.messaging.QueueConnectionFactory(); QueueConnection qc1 = null; qc1 = qcf.createQueueConnection(); QueueSession qs1 = qc1.createQueueSession(true,QueueSession.CLIENT_ACKNOWLEDGE); javax.jms.Queue que1 = qs1.createQueue ("TestQueue1"); QueueReceiver qRec = qs1.createReceiver(que1); QueueBrowser queueBrowse = qs1.createBrowser(qRec.getQueu   More>>

How do I use QueueBrowser? When I am sending and receiving messages simultaneously and then browsing for messages in Queue, it shows. When I am only trying to browse it doesn't show anything.
I am getting the enumeration from queueBrowser.
The code is given below.

com.sun.messaging.QueueConnectionFactory qcf = new com.sun.messaging.QueueConnectionFactory();

QueueConnection qc1 = null;
qc1 = qcf.createQueueConnection();

QueueSession qs1 = qc1.createQueueSession(true,QueueSession.CLIENT_ACKNOWLEDGE);

javax.jms.Queue que1 = qs1.createQueue ("TestQueue1");

QueueReceiver qRec = qs1.createReceiver(que1);

QueueBrowser queueBrowse = qs1.createBrowser(qRec.getQueue(),qRec.getMessageSelector());
Enumeration enum = queueBrowse.getEnumeration();
while (enum.hasMoreElements()) {
StreamMessage aMess = (StreamMessage) enum.nextElement();
//String id = (String)Mess.getJMSMessageID();
String s = aMess.readString();
System.out.println("The message is : " + s + " : ");
}

   <<Less
About | Sitemap | Contact