camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Issue trying to browse a activemq queue
Date Mon, 04 Jan 2010 16:27:41 GMT
Hi

In ActiveMQ 5.3 you can get stats as follows:
http://activemq.apache.org/statisticsplugin.html

That should be faster than the QueueBrowser interface as you have to
walk every message on the queue to know how many messages exists. So
getting the stats some other way is better and faster.

What do you need JNDI for? Do you run your code in some J2ee server or
the likes?


On Mon, Jan 4, 2010 at 4:26 PM, Ricardo Melo <ricardo@cflex.com.br> wrote:
> Hi,
>
> 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
> javax.naming.
> 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.
>        lookup("queue/connectionFactory");
>
>        // create a queue connection
>        QueueConnection queueConn = connFactory.createQueueConnection();
>
>        // create a queue session
>        QueueSession queueSession = queueConn.createQueueSession(false,
>        Session.AUTO_ACKNOWLEDGE);
>
>        // create a queue browser
>        QueueBrowser queueBrowser = queueSession.createBrowser(queue);
>
>        // start the connection
>        queueConn.start();
>
> Thanks in advance,
> Ricardo Melo
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message