1 24 package cluster.queue; 25 26 import org.objectweb.joram.client.jms.admin.*; 27 import org.objectweb.joram.client.jms.*; 28 import org.objectweb.joram.client.jms.tcp.*; 29 import org.objectweb.joram.shared.admin.*; 30 import org.objectweb.joram.client.jms.Queue; 31 32 import java.util.Properties ; 33 import java.util.Hashtable ; 34 35 38 public class ClusterAdmin { 39 public static void main(String [] args) throws Exception { 40 System.out.println(); 41 System.out.println("Cluster administration..."); 42 43 AdminModule admin = new AdminModule(); 44 admin.connect("root", "root", 60); 45 46 Properties prop = new Properties (); 47 prop.setProperty("period","100"); 48 prop.setProperty("producThreshold","25"); 49 prop.setProperty("consumThreshold","2"); 50 prop.setProperty("autoEvalThreshold","true"); 51 prop.setProperty("waitAfterClusterReq","100"); 52 53 59 String ClusterQueueCN = "org.objectweb.joram.mom.dest.ClusterQueue"; 60 61 Queue queue0 = Queue.create(0, null, ClusterQueueCN, prop); 62 Queue queue1 = Queue.create(1, null, ClusterQueueCN, prop); 63 Queue queue2 = Queue.create(2, null, ClusterQueueCN, prop); 64 65 System.out.println("queue0 = " + queue0); 66 System.out.println("queue1 = " + queue1); 67 System.out.println("queue2 = " + queue1); 68 69 User user0 = User.create("user0", "user0", 0); 70 User user1 = User.create("user1", "user1", 1); 71 User user2 = User.create("user2", "user2", 2); 72 73 javax.jms.QueueConnectionFactory cf0 = 74 QueueTcpConnectionFactory.create("localhost", 16010); 75 javax.jms.QueueConnectionFactory cf1 = 76 QueueTcpConnectionFactory.create("localhost", 16011); 77 javax.jms.QueueConnectionFactory cf2 = 78 QueueTcpConnectionFactory.create("localhost", 16012); 79 80 AdminHelper.setQueueCluster(queue0,queue1); 81 AdminHelper.setQueueCluster(queue0,queue2); 82 83 queue0.addClusteredQueue(queue1); 84 queue0.addClusteredQueue(queue2); 85 86 Hashtable h = new Hashtable (); 87 h.put("0",queue0); 88 h.put("1",queue1); 89 h.put("2",queue2); 90 91 ClusterQueue clusterQueue = new ClusterQueue(h); 92 System.out.println("clusterQueue = " + clusterQueue); 93 94 clusterQueue.setReader(user0); 95 clusterQueue.setWriter(user0); 96 clusterQueue.setReader(user1); 97 clusterQueue.setWriter(user1); 98 clusterQueue.setReader(user2); 99 clusterQueue.setWriter(user2); 100 101 javax.naming.Context jndiCtx = new javax.naming.InitialContext (); 102 jndiCtx.bind("qcf0", cf0); 103 jndiCtx.bind("qcf1", cf1); 104 jndiCtx.bind("qcf2", cf2); 105 jndiCtx.bind("clusterQueue", clusterQueue); 106 jndiCtx.bind("queue0", queue0); 107 jndiCtx.bind("queue1", queue1); 108 jndiCtx.bind("queue2", queue2); 109 jndiCtx.close(); 110 111 admin.disconnect(); 112 113 javax.naming.InitialContext jndiCtx2 = new javax.naming.InitialContext (); 114 clusterQueue = (ClusterQueue) jndiCtx2.lookup("clusterQueue"); 115 System.out.println("clusterQueue = " + clusterQueue); 116 jndiCtx2.close(); 117 118 System.out.println("Admins closed."); 119 } 120 } 121 | Popular Tags |