1 23 package cluster.queue; 24 25 import org.objectweb.joram.client.jms.admin.*; 26 import org.objectweb.joram.client.jms.*; 27 import org.objectweb.joram.client.jms.tcp.*; 28 import org.objectweb.joram.shared.admin.*; 29 import org.objectweb.joram.client.jms.Queue; 30 31 import java.util.Properties ; 32 import java.util.Hashtable ; 33 34 37 public class ClusterAdminAdd 38 { 39 public static void main(String [] args) throws Exception 40 { 41 System.out.println(); 42 System.out.println("Cluster administration Add ..."); 43 44 javax.naming.Context jndiCtx = new javax.naming.InitialContext (); 45 46 Properties prop = new Properties (); 47 prop.setProperty("period",args[0]); 48 prop.setProperty("producThreshold",args[1]); 49 prop.setProperty("consumThreshold",args[2]); 50 prop.setProperty("autoEvalThreshold",args[3]); 51 prop.setProperty("waitAfterClusterReq",args[4]); 52 System.out.println("prop = " + prop); 53 54 String sid = args[5]; 55 int id = new Integer (sid).intValue(); 56 String host = args[6]; 57 int port = new Integer (args[7]).intValue(); 58 59 AdminModule admin = new AdminModule(); 60 admin.connect(host,port,"root", "root", 60); 61 62 Queue queue = Queue.create( 63 id, 64 null, 65 "org.objectweb.joram.mom.dest.ClusterQueue", 66 prop); 67 68 System.out.println("queue = " + queue); 69 70 User user = User.create("user"+sid, "user"+sid, id); 71 72 73 javax.jms.QueueConnectionFactory cf = 74 QueueTcpConnectionFactory.create("localhost", 16010+id); 75 76 ClusterQueue cluster = (ClusterQueue) jndiCtx.lookup("clusterQueue"); 77 78 AdminHelper.setQueueCluster(cluster,queue); 79 80 Hashtable h = cluster.getCluster(); 81 h.put(sid,queue); 82 83 ClusterQueue clusterQueue = new ClusterQueue(h); 84 System.out.println("clusterQueue = " + clusterQueue); 85 86 clusterQueue.setReader(user); 87 clusterQueue.setWriter(user); 88 89 90 jndiCtx.bind("qcf"+sid, cf); 91 jndiCtx.rebind("clusterQueue",clusterQueue); 92 jndiCtx.bind("queue"+sid, queue); 93 jndiCtx.close(); 94 95 admin.disconnect(); 96 System.out.println("Admins closed."); 97 } 98 } 99 | Popular Tags |