1
2
3
4
5
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
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
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
63 e.printStackTrace();
64 } catch (JMSException e) {
65
66 e.printStackTrace();
67 }
68
69 }
70 }