Added logging to proc queue processing. Refactored code to delete request on failures. Restored MCP call in Service_Manager_Events to avoid issues calling certain procedures.

This commit is contained in:
Infineon\StieberD 2025-06-04 17:05:06 -07:00
parent 38fc89dac6
commit 869787e0f3
2 changed files with 51 additions and 15 deletions

View File

@ -108,7 +108,8 @@ Event WINDOW.TIMER()
Procedures = ServiceDetail<SERVICES.PROCEDURES$>
Arguments = ServiceDetail<SERVICES.ARGUMENTS$>
For Each Procedure in Procedures using @VM setting procPos
Command = 'RUN ' : Procedure
If Procedure[-9, 9] _EQC '_SERVICES' then Procedure[-9, 9] = ''
Command = 'RUN MCP ' : Quote(Procedure)
Arguments = Arguments<0, procPos>
If Arguments NE '' then
For Each Argument in Arguments using ','
@ -129,7 +130,7 @@ Event WINDOW.TIMER()
If Not(Num(Modifier)) then Modifier = ''
Argument = Date() + Modifier
end
Command := ' ' : Quote(Argument)
Command := ', ' : Quote(Argument)
Next Argument
end
Next Procedure

View File

@ -27,19 +27,29 @@ Function Service_Services(@Service, @Params)
#pragma precomp SRP_PreCompiler
$insert LOGICAL
$insert APP_INSERTS
$insert SERVICE_SETUP
$insert SERVICES_EQUATES
$insert RLIST_EQUATES
$insert SQL_REQUESTS_EQUATES
$Insert PROC_QUEUE_EQUATES
Equ Comma$ to ','
Common /ServiceServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@, Unused9@, Unused10@
Declare function Service_Services, Memory_Services, SRP_List, SRP_FastArray, SRP_Array, Database_Services, Datetime
Declare Function GetTickCount, SRP_Decode, RTI_CREATEGUID
Declare function GetTickCount, SRP_Decode, RTI_CreateGuid, UCase, Environment_services, Logging_Services
Declare subroutine Service_Services, Memory_Services, SRP_List, SRP_FastArray, RList, Set_Status, Database_Services
Declare Subroutine Yield, WinYield, Sleepery, Btree.Extract
Declare Subroutine Yield, WinYield, Sleepery, Btree.Extract, Logging_Services, obj_Notes
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ProcQueue'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Procedure Queue Log.csv'
Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'RequestKeyId' : @FM : 'Procedure' : @FM : 'Params' : @FM : 'Result' : @FM : 'Error Message'
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, Comma$, Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
GoToService else
Error_Services('Add', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.')
@ -165,18 +175,21 @@ Service ProcessProcedureQueue()
ReadNext RequestKeyID else EOF = True$
Until EOF or Done
Lock hProcQueue, RequestKeyID then
Server = Environment_Services('GetServer')
Done = True$
Database_Services('GetKeyIDLock', 'PROC_QUEUE', RequestKeyId)
RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID)
If RequestRow NE '' then
Procedure = RequestRow<PROC_QUEUE.PROC_NAME$>
Procedure = UCase(Procedure)
Params = RequestRow<PROC_QUEUE.PARAMS$>
If Procedure NE '' then
Dim ProcParams(11)
Dim ProcParams(12)
For each Param in Params using @VM setting pPos
ProcParams(pPos) = Param
Next Param
NumArguments = DCount(Params, @VM)
Begin Case
Case NumArguments EQ 0 ; Call @Procedure()
Case NumArguments EQ 1 ; Call @Procedure(ProcParams(1))
@ -194,17 +207,40 @@ Service ProcessProcedureQueue()
Error_Services('Add', 'Error in ':Service:' service. More than 11 arguments are not currently supported.')
End Case
end
If Error_Services('NoError') then
Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) ; // This call will release the lock
Swap @VM with ',' in Params
LogData = LoggingDTM
LogData<2> = Server
LogData<3> = RequestKeyId
LogData<4> = Procedure
LogData<5> = Params
ErrCode = ''
If ( Get_Status(ErrCode) or Error_Services('HasError') ) then
ErrorMessage = Error_Services('GetMessage')
Recipients = ''
SentFrom = 'SYSTEM'
Subject = 'Background Procedure Queue Error'
Message = OConv(Datetime(), 'DT2/^H')
Message<2> = 'Error on server ':Server
Message<3> = 'Stored Procedure: ':Procedure
StatCodes = 'Parameters: ':Params
Message<4> = 'Error_Services error message: ':ErrorMessage
Message<5> = 'Get_Status error code: ':ErrCode
Swap @FM with \0D0A\ in Message
AttachWindow = ''
AttachKey = ''
SendToGroup = 'OI_SYSADMIN'
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
obj_Notes('Create',Parms)
LogData<6> = 'Failed'
LogData<7> = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode
end else
RequestRow<PROC_QUEUE.LAST_ATTEMPT_DTM$> = DateTime()
RequestRow<PROC_QUEUE.ERROR$> = Error_Services('GetMessage')
Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, False$) ; // This call will release the lock
LogData<6> = 'Success'
end
end else
// Empty request, so delete it from the queue
Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) ; // This call will release the lock
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
end
Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) ; // This call should release the lock
Unlock hProcQueue, RequestKeyID else Null
end
Repeat
end
@ -258,4 +294,3 @@ return
/// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////