developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks




Mail-In agent runs over processed docs at night
Peter Gloor 03/27/2007 12:05 PM
Domino Server 6.0.2 CF2 Windows 2003


I have a Mail-In agent (after new mail has arrived) which behaves very strange. Each night, at some time between 02:00 and 06:00 in the morning my Mail-In agent starts running without having received a document and processes any document that has entered into this database by mail. The same occurs whnever I restart the agent manager.

Despite the fact I have a Call session.UpdateProcessedDoc( doc ) for each document the documents are processed again even they already have been processed by this Mail-In-Agent.

I have other Mail-In agents on the same server that work without problems. If I copy the source code of the agent and create a similar agent in another database, the new agent fails too. So what's wrong with my code? Is the call of another agent (agent list selection, target: none) near the end of the mail-in agent the cause of all the problems?

Questions:
1) What triggers the agent at night, if there is no incoming mail (for sure).

2) Why does the agent process the already processed documents each night again?

This is how my code looks like (some parts removed):

Sub Initialize
Dim session As New NotesSession
' declare more objects and variables and do some initialization
' ...

Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments

Redim strArrSelectedDocuments( dc.Count - 1)
i = 0
Set doc = dc.GetFirstDocument
While Not doc Is Nothing
' Add Universal ID to the array with the list of documents
strArrSelectedDocuments( i ) = doc.UniversalID
i= i + 1

' Mark document as processed by this agent
Call session.UpdateProcessedDoc( doc )
Set doc = dc.GetNextDocument( doc )
Wend
'
' Do some more processing and add the result to a profile doc
' ...

' Call the dispatcher (Note: Dispatcher uses a script library)
Set agent = db.GetAgent("Dispatcher")
Call agent.RunOnServer()
Exit Sub

As a workaround I'm now setting a flag into the processed documents and process only documents that don't have the flag set. But isn't this what UpdateProcessedDoc should do anyway?

Any ideas are welcome.

Peter

Go back