String msgsPerShipStr = System.getProperty("requests-per-shipment");
int totalShip = (totalShipStr == null ? 10 : Integer.parseInt(totalShipStr));
int msgsPerShip = (msgsPerShipStr == null ? 20 : Integer.parseInt(msgsPerShipStr));
JmsBmtRemote jmsSender = (JmsBmtRemote) ctx.lookup("JmsBmtRemote");
boolean pass = true;
if (jmsSender != null) {
System.out.println("JmsBmtRemote 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);
String result = jmsSender.sendMessageQueue(messageName, 0, msgsPerShip);
System.out.println("QUeue equests sent, result: " + result);
if ("FAIL".equals(result)) pass = false;
result = jmsSender.sendMessageTopic(messageName, 0, msgsPerShip);
System.out.println("Topic requests sent, result: " + result);
if ("FAIL".equals(result)) pass = false;
}
if (!pass) {
throw new Exception("Failed, see out and logs");