You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by petera <pe...@egsgroup.com> on 2007/01/12 13:16:49 UTC
QueueBrowser
Hi,
I am using activemq ver 4.0.1 on a mac running OS x 10.4.8
I am trying to use the queue browser to view messages on a queue but it does
not seem to work. No messages
are being returned when i issue the command:
Enumeration msgs = browser.getEnumeration();
There are definitely messages on the queue and i can see them in the
persistent activemq_msgs table.
Is this a bug ? Or am i doing something wrong ?
CODE:
try
{
/*
* Create a JNDI API Initial Context object.
*/
InitialContext init = new InitialContext() ;
Context envContext = (Context) init.lookup("java:comp/env") ;
/*
* Look up Connection Factory and destination.
*/
ConnectionFactory connectionFactory = (ConnectionFactory)
envContext.lookup("jms/ConnectionFactory") ;
Queue queue = (Queue) envContext.lookup("jms/InvoiceQueue") ;
connection = connectionFactory.createConnection();
session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
QueueBrowser browser = session.createBrowser(queue);
Enumeration msgs = browser.getEnumeration();
if (!msgs.hasMoreElements()) {
out.println("No messages in queue");
} else {
while (msgs.hasMoreElements()) {
Message tempMsg = (Message) msgs.nextElement();
out.println("Message: " + tempMsg);
}
}
} catch (JMSException e) {
out.println("Exception occurred: " + e.toString());
}
catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
}
}
}
--
View this message in context: http://www.nabble.com/QueueBrowser-tf2965665.html#a8297397
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: QueueBrowser
Posted by petera <pe...@egsgroup.com>.
James
Thanks that was the problem.
Peter
James.Strachan wrote:
>
> This one has got me so many times with JMS.
>
> http://incubator.apache.org/activemq/i-am-not-receiving-any-messages-what-is-wrong.html
>
> On 1/12/07, petera <pe...@egsgroup.com> wrote:
>>
>> Hi,
>>
>> I am using activemq ver 4.0.1 on a mac running OS x 10.4.8
>>
>> I am trying to use the queue browser to view messages on a queue but it
>> does
>> not seem to work. No messages
>> are being returned when i issue the command:
>> Enumeration msgs = browser.getEnumeration();
>>
>> There are definitely messages on the queue and i can see them in the
>> persistent activemq_msgs table.
>>
>> Is this a bug ? Or am i doing something wrong ?
>>
>> CODE:
>>
>>
>> try
>> {
>> /*
>> * Create a JNDI API Initial Context object.
>> */
>> InitialContext init = new InitialContext() ;
>> Context envContext = (Context) init.lookup("java:comp/env")
>> ;
>> /*
>> * Look up Connection Factory and destination.
>> */
>> ConnectionFactory connectionFactory = (ConnectionFactory)
>> envContext.lookup("jms/ConnectionFactory") ;
>>
>> Queue queue = (Queue) envContext.lookup("jms/InvoiceQueue")
>> ;
>>
>> connection = connectionFactory.createConnection();
>>
>> session = connection.createSession(false,
>> Session.AUTO_ACKNOWLEDGE);
>>
>> QueueBrowser browser = session.createBrowser(queue);
>> Enumeration msgs = browser.getEnumeration();
>>
>> if (!msgs.hasMoreElements()) {
>> out.println("No messages in queue");
>> } else {
>> while (msgs.hasMoreElements()) {
>> Message tempMsg = (Message) msgs.nextElement();
>> out.println("Message: " + tempMsg);
>> }
>> }
>> } catch (JMSException e) {
>> out.println("Exception occurred: " + e.toString());
>> }
>> catch (NamingException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> } finally {
>> if (connection != null) {
>> try {
>> connection.close();
>> } catch (JMSException e) {
>> }
>> }
>> }
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/QueueBrowser-tf2965665.html#a8297397
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
>
--
View this message in context: http://www.nabble.com/QueueBrowser-tf2965665.html#a8299489
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: QueueBrowser
Posted by James Strachan <ja...@gmail.com>.
This one has got me so many times with JMS.
http://incubator.apache.org/activemq/i-am-not-receiving-any-messages-what-is-wrong.html
On 1/12/07, petera <pe...@egsgroup.com> wrote:
>
> Hi,
>
> I am using activemq ver 4.0.1 on a mac running OS x 10.4.8
>
> I am trying to use the queue browser to view messages on a queue but it does
> not seem to work. No messages
> are being returned when i issue the command:
> Enumeration msgs = browser.getEnumeration();
>
> There are definitely messages on the queue and i can see them in the
> persistent activemq_msgs table.
>
> Is this a bug ? Or am i doing something wrong ?
>
> CODE:
>
>
> try
> {
> /*
> * Create a JNDI API Initial Context object.
> */
> InitialContext init = new InitialContext() ;
> Context envContext = (Context) init.lookup("java:comp/env") ;
> /*
> * Look up Connection Factory and destination.
> */
> ConnectionFactory connectionFactory = (ConnectionFactory)
> envContext.lookup("jms/ConnectionFactory") ;
>
> Queue queue = (Queue) envContext.lookup("jms/InvoiceQueue") ;
>
> connection = connectionFactory.createConnection();
>
> session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
> QueueBrowser browser = session.createBrowser(queue);
> Enumeration msgs = browser.getEnumeration();
>
> if (!msgs.hasMoreElements()) {
> out.println("No messages in queue");
> } else {
> while (msgs.hasMoreElements()) {
> Message tempMsg = (Message) msgs.nextElement();
> out.println("Message: " + tempMsg);
> }
> }
> } catch (JMSException e) {
> out.println("Exception occurred: " + e.toString());
> }
> catch (NamingException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } finally {
> if (connection != null) {
> try {
> connection.close();
> } catch (JMSException e) {
> }
> }
> }
>
>
>
>
> --
> View this message in context: http://www.nabble.com/QueueBrowser-tf2965665.html#a8297397
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
--
James
-------
http://radio.weblogs.com/0112098/