activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Priya Parvatikar <priya.parvati...@ingenta.com>
Subject QueueBrowser in embedded broker not getting any messages
Date Tue, 21 Nov 2006 05:56:36 GMT

Hi,

I am trying to use a QueueBrowser to browse messages sent using an embedded
broker.  I am using ActiveMQ version 4.0.2.  The broker is set up using 

new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");

However the QueueBrowser doesn't appear to get any messages i.e.
browser.getEnumeration().hasMoreElements() returns false.  Here's the code I
am using - 

public void initialise(){
    try {
        ConnectionFactory connFactory = new
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");		
        Connection connection = connFactory.createConnection();
        Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
        javax.jms.Queue queue =
(javax.jms.Queue)jndiUtil.getJndiEntry(queueName);
        browser = session.createBrowser(queue);
        connection.start();
    } catch (NamingException e) {
	System.err.println("Got NamingException : " + e.getMessage());
    } catch (JMSException e) {
	System.err.println("Got JMSException : " + e.getMessage());
    }

}

public void browseMessages {
    try {
        Enumeration msgEnum = browser.getEnumeration();
        System.out.println("has more elements is " +
msgEnum.hasMoreElements());
    }catch (JMSException e) {
	System.err.println("Got JMSException : " + e.getMessage());
    }
    
}

The initialise() method is called before the sender sends messages to the
queue and the browseMessages() method is called after the sender has sent a
message.  Could you please advise me about this?  Apologies if I am missing
something obvious.

Thanks,
Priya



-- 
View this message in context: http://www.nabble.com/QueueBrowser-in-embedded-broker-not-getting-any-messages-tf2677079.html#a7466254
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message