String msgsPerShipStr = System.getProperty("requests-per-shipment");
int totalShip = (totalShipStr == null ? 10 : Integer.parseInt(totalShipStr));
int msgsPerShip = (msgsPerShipStr == null ? 20 : Integer.parseInt(msgsPerShipStr));
JmsSenderRemote jmsSender = (JmsSenderRemote) ctx.lookup("JmsSenderRemote");
if (jmsSender != null) {
System.out.println("JmsSender initialized");
for (int i = 0; i < totalShip; ++i) {
String messageName = (i + 1) + ".Request";
System.out.format("Sending (%1$s) request(s) with name %2$s%n", msgsPerShip, messageName);
jmsSender.sendMessage(messageName, 0, msgsPerShip);
System.out.println("Requests sent");
}
//enable is receiveMessage is modified to detect messages on request queue
/*
Thread.sleep(10000);
Integer id = jmsSender.receiveMessage();
if (id != null) {
throw new Exception("received request message: " + id);
}
*/
//uncomment to actually run test
for (int i = 0; i < totalShip * msgsPerShip; i++) {
Integer id = jmsSender.receiveMessage();
if (id == null) {
throw new Exception("did not receive message: " + i);
// System.out.println("Did not receive message: " + i);
// Thread.sleep(10000);
}