camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Melo <>
Subject Issue trying to browse a activemq queue
Date Mon, 04 Jan 2010 15:26:08 GMT

I'm using camel and I need to get the number of elements present in a
activemq queue, because the queue has a max size.

I'm trying to use QueueBrowser Interface, with no success. The queue I put
messages in is called "activemq:queue:out".

I've found some code to do that job, but I can't connect to the queue, a
NoInitialContextException is thrown at the identified line showed bellow.
The connection string is not working. What should I use to connect to the
queue created by camel?

Here is the code:

        // get the initial context
        InitialContext ctx = new InitialContext();

        // lookup the queue object
        [EXCEPTION!] Queue queue = (Queue) ctx.lookup("queue:out");

        // lookup the queue connection factory
        QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.

        // create a queue connection
        QueueConnection queueConn = connFactory.createQueueConnection();

        // create a queue session
        QueueSession queueSession = queueConn.createQueueSession(false,

        // create a queue browser
        QueueBrowser queueBrowser = queueSession.createBrowser(queue);

        // start the connection

Thanks in advance,
Ricardo Melo

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message