- 
        1. Re: how to delete/create queue because InstanceAlreadyExistsadrian.brock Nov 3, 2002 8:52 PM (in response to garyg)destroyQueue 
 Regards,
 Adrian
- 
        2. Re: how to delete/create queue because InstanceAlreadyExistsgaryg Nov 10, 2002 3:03 AM (in response to garyg)I was hoping I'd be able to catch an InstanceAlreadyExistsException where I'd then call destroyQueue, but since I'm using the http adaptor to createQueue from a client, I can't catch this exception. 
 Is there anyway to check to see if the queue exists first?
- 
        3. Re: how to delete/create queue because InstanceAlreadyExistsadrian.brock Nov 10, 2002 9:26 AM (in response to garyg)import javax.management.*; 
 ObjectName name = new ObjectName(<queue-mbean-here>);
 // Get the MBeanServer
 MBeanServer server = MBeanServerFactory.findMBeanServer(null).iterator().next();
 // Is the queue registered
 boolean registered = server.isRegistered(name);
 You can also use server.invoke(...) to create and
 destroy the queues.
 If you are not local to the VM, you can use the
 RMI or EJB adaptor.
 Regards,
 Adrian
- 
        4. Re: how to delete/create queue because InstanceAlreadyExistsgaryg Nov 10, 2002 5:43 PM (in response to garyg)So I'm using the RMIAdaptor since I'm not local to the VM. But I'm getting the following exceptions ... 
 javax.naming.CommunicationException: Peek timed out. Root exception is java.io.InterruptedIOException: Peek timed out
 at java.net.PlainDatagramSocketImpl.peek(Native Method)
 at java.net.DatagramSocket.receive(DatagramSocket.java:349)
 at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:930)
 at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1017)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:447)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:440)
 at javax.naming.InitialContext.lookup(InitialContext.java:345)
 And here's my clients code ...
 ---
 String adaptorName = "jmx:" + props.getProperty("manager.name")
 + ":rmi";
 try {
 InitialContext ctx = new InitialContext();
 RMIAdaptor adaptor = (RMIAdaptor) ctx.lookup(adaptorName);
 ObjectName name = new ObjectName("jboss.system:service=MainDeployer");
 RemoteMBeanServer server = new RMIConnectorImpl(adaptor);
 boolean registered = server.isRegistered(name);
 if (registered) {
 server.invoke(name, "destroyQueue", new Object[] { server },
 new String[] {});
 }
 server.invoke(name, "createQueue", new Object[] { server },
 new String[] {});
 Any help much appreciated.
- 
        5. Re: how to delete/create queue because InstanceAlreadyExistsadrian.brock Nov 10, 2002 10:58 PM (in response to garyg)You have a problem with your jndi.properties? 
 When you've fixed that your object names are wrong.
 The isRegistered() should use the Queue's object name.
 The create/destroy queue should be against the
 DestinationManager.
 Regards,
 Adrian
- 
        6. Re: how to delete/create queue because InstanceAlreadyExistsgaryg Nov 15, 2002 10:06 PM (in response to garyg)Still getting the exceptions which I've pasted at the end. I've also included the jndi.properties which I don't see anything wrong with. 
 java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
 java.naming.provider.url=jnp://192.168.0.10:1099/
 java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
 #jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory
 #jnp.timeout=0
 #jnp.sotimeout=0
 --- And here is the new code fixes ...
 try {
 InitialContext ctx = new InitialContext();
 RMIAdaptor adaptor = (RMIAdaptor) ctx.lookup(adaptorName);
 ObjectName name = new
 ObjectName("jboss.mq:service=DestinationManager");
 RemoteMBeanServer server = new RMIConnectorImpl(adaptor);
 ObjectName queName = new ObjectName("queue/" +
 props.getProperty("fielder.hostname"));
 boolean registered = server.isRegistered(queName);
 String[] sig = {"java.lang.String"};
 Object[] arg = {props.getProperty("fielder.hostname")};
 if (registered) {
 log.info(Fielder.class, "already registered, destroying queue");
 server.invoke(name, "destroyQueue", arg, sig);
 }
 log.info(Fielder.class, "creating queue");
 server.invoke(name, "createQueue", arg, sig);
 --- jboss output ---
 javax.naming.CommunicationException: Peek timed out. Root exception is java.io.InterruptedIOException: Peek timed out
 at java.net.PlainDatagramSocketImpl.peek(Native Method)
 at java.net.DatagramSocket.receive(DatagramSocket.java:349)
 at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:930)
 at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1017)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:447)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:440)
 at javax.naming.InitialContext.lookup(InitialContext.java:345)
 at com.neuroquest.cais.clients.fielder.Fielder.createPTP(Unknown Source)
 at com.neuroquest.cais.clients.fielder.Fielder.main(Unknown Source)
 Any help much appreciated.
 
    