-
1. Re: How do I get a list of queues at runtime?
mskonda May 5, 2006 9:59 AM (in response to joejack)I don't see any reason why you can't get the destination list from JNDI.
Use the following code:private void listQueues() throws NamingException { ic = new InitialContext(); cf = (ConnectionFactory) ic.lookup("ConnectionFactory"); NamingEnumeration ne = ic.list("queue");//or topic while(ne.hasMoreElements()){ NameClassPair dn = (NameClassPair)ne.nextElement(); System.out.println("destination: "+dn.getName()); } Destination queue = (Queue) ic.lookup(dn.getName()); }
What I am doing here is fetching the String equivalent of Queues (or Topics) from JNDI in a list and looping through the list.
For your second question, use temporary queues
/K -
2. Re: How do I get a list of queues at runtime?
joejack May 5, 2006 12:19 PM (in response to joejack)Thanks for the reply. I had thought about using JNDI to get a list but was hoping there was a more direct way via the DestinationManager. I'm a little concerned that there is a possibility for JNDI and the DestinationManager to be out of synch at some points. I would sure like to see a reply from JBoss as to what their paradigm is for such a task.
After looking at this code I have to ask: What is the point of getting a reference to the ConnectionFactory? Is there something behind the scenes that requires it?
Also, are there any good examples of using TemporaryQueues? I haven't found any JBoss documentation that covers temporary queues...ConnectionFactories and Destinations are very vendor-specific objects.
Thanks.