View Javadoc

1   /*
2    * Created on 20-sep-2004
3    *
4    * TODO To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
6    */
7   package com.wickle.clanwar.client;
8   
9   /***
10   * @author vic
11   *
12   * TODO To change the template for this generated type comment go to
13   * Window - Preferences - Java - Code Style - Code Templates
14   */
15  import java.net.MalformedURLException;
16  import java.util.Iterator;
17  import java.util.Vector;
18  
19  import javax.jms.Destination;
20  import javax.jms.JMSException;
21  import javax.jms.Queue;
22  import javax.jms.Topic;
23  
24  import org.exolab.jms.administration.AdminConnectionFactory;
25  import org.exolab.jms.administration.JmsAdminServerIfc;
26  
27  public class testJMS {
28  
29  	public void testjms() {
30  		
31  		try {
32  			//String url = "rmi://192.168.0.18:1099/";
33  			String url = "http://213.60.51.54:8080/";
34  			JmsAdminServerIfc admin = AdminConnectionFactory.create(url);
35  			
36  			Vector destinations = admin.getAllDestinations();
37  			Iterator iterator = destinations.iterator();
38  			while (iterator.hasNext()) {
39  				Destination destination = (Destination) iterator.next();
40  				if (destination instanceof Queue) {
41  					Queue queue = (Queue) destination;
42  					System.out.println("queue:" + queue.getQueueName());
43  				} else {
44  					Topic topic = (Topic) destination;
45  					System.out.println("topic:" + topic.getTopicName());
46  				}
47  			}
48  			
49  			
50  			//Create a queue ...
51  		    String queue = "myqueuemacame";
52  		    Boolean isQueue = Boolean.TRUE;
53  		    if (!admin.addDestination(queue, isQueue)) {
54  		        System.err.println("Failed to create queue. It exists " + queue);
55  		    }
56  		    
57  		    
58  		    
59  			
60  			admin.close();
61  		} catch (MalformedURLException e) {
62  			// TODO Auto-generated catch block
63  			e.printStackTrace();
64  		} catch (JMSException e) {
65  			// TODO Auto-generated catch block
66  			e.printStackTrace();
67  		}
68  		
69  	}
70  }