static Context ictx = null;
public static void main(String[] args) throws Exception {
ConnectionFactory cf = null;
Topic dest = null;
if (args.length != 1)
throw new Exception("Bad number of argument");
ictx = new InitialContext();
try {
if (args[0].equals("-")) {
// Choose a connection factory and the associated topic depending of
// the location property.
cf = (ConnectionFactory) ictx.lookup("clusterCF");
dest = (Topic) ictx.lookup("clusterTopic");
} else {
cf = (ConnectionFactory) ictx.lookup("cf" + args[0]);
dest = (Topic) ictx.lookup("topic" + args[0]);
System.setProperty("location", "server" + args[0]);
}
} finally {
ictx.close();
}
Connection cnx = cf.createConnection("anonymous", "anonymous");
Session session = cnx.createSession(true, 0);
MessageProducer pub = session.createProducer(dest);
String location = System.getProperty("location");
if (location != null)