aspose file tools*
The moose likes Java in General and the fly likes MQ : error while browsing queues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "MQ : error while browsing queues" Watch "MQ : error while browsing queues" New topic

MQ : error while browsing queues

Vallaru smitha
Ranch Hand

Joined: Aug 19, 2008
Posts: 87


I am trying browse a queue which has write only permissions and I am trying to catch an exception in catch block and print a message that the queus has only wite permissions in system log depending on the reason code.

try {

InitialContext ctx = new InitialContext();
qcf = (QueueConnectionFactory) ctx.lookup(qcfName);
queue = (Queue) ctx.lookup(queueName);
queueConnection = qcf.createQueueConnection();
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queueBrowser = queueSession.createBrowser(queue);

Enumeration enum = queueBrowser.getEnumeration();
while (enum.hasMoreElements()) {
Message msg = (Message) enum.nextElement();
} catch (NamingException ne) {
} catch (JMSException jmse) {

} catch (Exception e) {
} finally {
try {
} catch (Exception e) {

Since the queue is not browsable when i say queueBrowser.getEnumerations should't it go to catch block . But in mycode it passes through the enumeration to finally block and close the browser.

Any help is apperiacitaed.

Vallaru smitha
Ranch Hand

Joined: Aug 19, 2008
Posts: 87

bump up
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36475
Vallaru smitha wrote:bump up
Patience, patience.
Vallaru smitha
Ranch Hand

Joined: Aug 19, 2008
Posts: 87

Sorry, I can understand but I am kind of struck so i just bumbed up.

This is what I undestood enum always returns something eventhou the queue is not browsable .

Enumeration enum = queueBrowser.getEnumeration();

Could anyone please let me now if there way i could throw and catch when queue is not broswable.

I agree. Here's the link:
subject: MQ : error while browsing queues
Similar Threads
JMS Help: send a queue message with reply
JMS example
P2P using WSAD's embedded JMS- Naming Exception
Distributed Transactions