Managing an unstable SQL connection on a Lotus Notes Agent
I have a working Lotus Notes agent. Running on LN 7. My agent runs every 5 minutes, and it sends some mails whenever it finds some specific records on an Microsoft SQL (2005) table.
It usually works ok, but recently it stopped working -more than once now- and won't restart again until the Notes Server is restarted or the Notes admin restarts all the agents (I'm no notes admin, so I'm not really sure what he does, I'm trying to get this info to add to this question).
I'm trying to rule out anything I can think of and the only thing that comes to my mind is that the MS SQL Server on which my LN Agent runs the queries had some s开发者_如何学Pythontability issues and might not always be online... I thought that that might be the cause of the problem... (I'm trying to cross reference the uptime log from the SQL with the last time my agent has completed successfully).
I was thinking if there's any way to manage the connection, other than what I'm doing, so I can rule out a (lack of) connection problem.
Thanks in advance for any advice you can provide.
Kind regards,
Diego
Option Public
Uselsx "*LSXODBC"
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim subject As String, cc As String, bcc As String, sender As String, OID As String, mailto As String, bodyNotMIME As String
Dim body As NotesMIMEEntity
On Error Goto errorCounter
Set db = session.CurrentDatabase
Gosub SendMailGeneral
Exit Sub
SendMailGeneral:
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim defaultQuery As String
Set qry.Connection = con
If con.ConnectTo("DSN_Name","USER_NAME", "PASSWORD") Then
Set result.Query = qry
defaultQuery = "select TOP (10) * from Message where StatusType=0"
qry.SQL = defaultQuery
result.Execute
If (result.IsResultSetAvailable) Then
Do
result.NextRowcode
//here´s all the code that gets the results from each table´s fields and transform them into notes mails
Loop Until result.IsEndOfData
End If
End If
result.Close(DB_CLOSE)
Return
End Sub
I've had a very similar issue (in Domino 6.0.4) and it was due to a bug. It's been a while so I don't remember where I found that it reported as a but (probably on notes.net), but I spent many many hours trying to figure out a workaround. In my situation, the only fix was to reboot the server.
Have your admin check the logs for any error messages around the time the agent fires. You could also add some print statements to the agent, which get written to the log, just to confirm the agent is running.
If your issue is the same as mine, the symptoms will be:
- the agent runs fine but there's an error in the log related to sending messages.
- Any other agents that send mail will also be affected.
- It works fine for weeks, even months, then suddenly stops working.
- and unfortunately, the only fix I've ever found is to reboot when it happens.
Just in case someone else has this same issue:
We finally found out that there where some timeout errors from the SQL server, and there was an error message prompt on the Notes server that would block the agent for running until clicked on the ok button (!).
In order to avoid these "visual" prompt errors on the server I found out about the SilentMode option on my OCBC connection definition: here's what you have to do:
con.SilentMode = True
Thanks anyway!
精彩评论