I have this java agent for testing( see code below). The agent completes fine, if (x<1) is specified in the for loop condition. But if I make it loop twice, then the agent (run on local designer client) seems to hang. Both messages recieved fine, but in the agent log, logging never reaches the “end” line. No error, since agent is running on local machine, the java console is always empty after I restart client…
I am new to java, so can you spot anything obviously wrong here? many thx in adv
import lotus.domino.*;
public class TestSendMemoInLoop extends AgentBase {
Session s;
AgentContext ac;
Database db;
Document memo;
Log log;
String m = new String();
public void NotesMain() {
try {
s = getSession();
ac = s.getAgentContext();
db = ac.getCurrentDatabase();
log = s.createLog("TestSendMailInLoop in " + db.getTitle() + " on " + db.getServer());
log.openNotesLog(null, "alog4.nsf");
log.logAction("started");
for (int x=0; x < 2; x++) {
memo = db.createDocument();
memo.replaceItemValue("Form", "Memo");
if (x==0)
m="A";
else
m="B";
memo.replaceItemValue("Subject", "send email in loop" + m);
memo.replaceItemValue("SendTo", "Xun.Dong@thomasmiller.com");
memo.setSaveMessageOnSend(true);
boolean suc = memo.computeWithForm(true, false);
log.logAction("about to send memo " + memo.getItemValueString("Subject"));
memo.send();
memo.recycle();
//memo=null;
}
if (memo!=null)
memo.recycle();
if (db!=null)
db.recycle();
if (ac!=null)
ac.recycle();
if (s!=null)
s.recycle();
log.logAction("end");
System.out.println("Testsendmemoinloop ended");
} catch (NotesException ne) {
ne.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}