Java Reference
In-Depth Information
Click here to view code image
final int NUM_MSGS;
String destType = args[0];
System.out.println("Destination type is " + destType);
if ( ! ( destType.equals("queue") || destType.equals("topic") ) )
{
System.err.println("Argument must be \"queue\" or " + "\"top-
ic\"");
System.exit(1);
}
if (args.length == 2){
NUM_MSGS = (new Integer(args[1])).intValue();
}
else {
NUM_MSGS = 1;
}
3. Assigns either the queue or the topic to a destination object, based on the specified
destination type:
Click here to view code image
Destination dest = null;
try {
if (destType.equals("queue")) {
dest = (Destination) queue;
} else {
dest = (Destination) topic;
}
}
catch (Exception e) {
System.err.println("Error setting destination: " +
e.toString());
e.printStackTrace();
System.exit(1);
}
4. Creates a Connection and a Session :
Click here to view code image
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(
false,
Session.AUTO_ACKNOWLEDGE);
Search WWH ::




Custom Search