camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Melo <rica...@cflex.com.br>
Subject Re: Issue trying to browse a activemq queue
Date Mon, 04 Jan 2010 17:06:51 GMT
Thank you all fot the answers.

It works now with the Browsable endpoint, thanks!

Very clean and elegant solution.

On Mon, Jan 4, 2010 at 2:33 PM, James Strachan <james.strachan@gmail.com>wrote:

> BTW it looks like you are confusing the queue name in JMS with the
> JNDI name in JNDI.
>
> Incidentally a simpler alternative to using the JNDI API to lookup the
> queue then using the JMS API to use a queue browser is to just use the
> BrowseableEndpoint API in Camel...
> http://camel.apache.org/browsableendpoint.html
>
> BrowseableEndpoint endpoint =
> camelContext.getEndpoint("activemq:queue:out",
> BrowseableEndpoint.class);
> int messageCount = endpoint.getExchanges().size();
>
>
> 2010/1/4 Ricardo Melo <ricardo@cflex.com.br>:
> > 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
> >
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>



-- 
Ricardo Britto Melo

CFlex - Empower your Decisions
Tel: (+55 19) 3251-5211
Rua BarĂ£o de Paranapanema, 401A
Campinas - SP
www.cflex.com.br

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