I'm using the Domino Java API to query a database on a remote server. The server is processing the documents, and I'm trying to get their status. However, when I create the session, and run a query, even if I loop and check again every 30 seconds, my code will never see those documents update- it only sees the status at the time it created the first query. I have a few more loops, but the basic code outline is below- can someone tell me what I'm doing wrong?
Is there a way to update the current Database view from the Java API? The databases are not full text indexed, and cannot be due to outside constraints.
public static boolean queryDatabase(String adminFilePath, String targetItem)
NotesThread.sinitThread();
Session session =NotesFactory.createSession((String) null, (String) null, (String) null);
Registration Reg = s.createRegistration();
Reg.switchToID(adminFilePath, password);
DocumentCollection dc = getRecentDocsFromDB(session);
numResults=dc.getCount();
if (numResults > 0) {
//loop through documents to find what I'm looking for
//if the documents contain "done", finish, else:
Thread.sleep(60000);
session.recycle();
session=SessionFactory.newSession(adminFilePath, "password");
dc = getRecentDocsFromDB(session);
found = searchDocumentCollection(dc, targetItem);
//this is essentially doing the same thing again- create a session, get docs made in the
//past day or so, and loop through looking for the ones I need.
}
private static DocumentCollection getRecentDocsFromDB(Session session){
Database db = SessionFactory.openDatabase(session, server, database);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
DateTime dt = session.createDateTime(cal);
DocumentCollection dc = searchNotesDBUsingDate(session, db,"Form=\"event\"", dt);
}
public static DocumentCollection searchNotesDBUsingDate(Session session,
Database database, String query, DateTime dt) throws NotesException {
DocumentCollection dc = null;
dc = database.search(query, dt);
return dc;
}
I've updated the code with a session.recycle() call. (Thanks for the suggestion!) In testing, it's not having any effect- the code is working for the first document, but then never sees a second document being called. It's insane, because it seems to be caching the session anyway!
numResults
in your loop? – Ordousrecycle
, but I'm really grasping at straws here - my experience is with Hibernate and Spring. – Ordous