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:
parent
38fc89dac6
commit
869787e0f3
@ -108,7 +108,8 @@ Event WINDOW.TIMER()
|
|||||||
Procedures = ServiceDetail<SERVICES.PROCEDURES$>
|
Procedures = ServiceDetail<SERVICES.PROCEDURES$>
|
||||||
Arguments = ServiceDetail<SERVICES.ARGUMENTS$>
|
Arguments = ServiceDetail<SERVICES.ARGUMENTS$>
|
||||||
For Each Procedure in Procedures using @VM setting procPos
|
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>
|
Arguments = Arguments<0, procPos>
|
||||||
If Arguments NE '' then
|
If Arguments NE '' then
|
||||||
For Each Argument in Arguments using ','
|
For Each Argument in Arguments using ','
|
||||||
@ -129,7 +130,7 @@ Event WINDOW.TIMER()
|
|||||||
If Not(Num(Modifier)) then Modifier = ''
|
If Not(Num(Modifier)) then Modifier = ''
|
||||||
Argument = Date() + Modifier
|
Argument = Date() + Modifier
|
||||||
end
|
end
|
||||||
Command := ' ' : Quote(Argument)
|
Command := ', ' : Quote(Argument)
|
||||||
Next Argument
|
Next Argument
|
||||||
end
|
end
|
||||||
Next Procedure
|
Next Procedure
|
||||||
|
@ -27,19 +27,29 @@ Function Service_Services(@Service, @Params)
|
|||||||
|
|
||||||
#pragma precomp SRP_PreCompiler
|
#pragma precomp SRP_PreCompiler
|
||||||
|
|
||||||
$insert LOGICAL
|
$insert APP_INSERTS
|
||||||
$insert SERVICE_SETUP
|
$insert SERVICE_SETUP
|
||||||
$insert SERVICES_EQUATES
|
$insert SERVICES_EQUATES
|
||||||
$insert RLIST_EQUATES
|
$insert RLIST_EQUATES
|
||||||
$insert SQL_REQUESTS_EQUATES
|
$insert SQL_REQUESTS_EQUATES
|
||||||
$Insert PROC_QUEUE_EQUATES
|
$Insert PROC_QUEUE_EQUATES
|
||||||
|
|
||||||
|
Equ Comma$ to ','
|
||||||
|
|
||||||
Common /ServiceServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@, Unused9@, Unused10@
|
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 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 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
|
GoToService else
|
||||||
Error_Services('Add', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.')
|
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$
|
ReadNext RequestKeyID else EOF = True$
|
||||||
Until EOF or Done
|
Until EOF or Done
|
||||||
Lock hProcQueue, RequestKeyID then
|
Lock hProcQueue, RequestKeyID then
|
||||||
|
Server = Environment_Services('GetServer')
|
||||||
Done = True$
|
Done = True$
|
||||||
Database_Services('GetKeyIDLock', 'PROC_QUEUE', RequestKeyId)
|
Database_Services('GetKeyIDLock', 'PROC_QUEUE', RequestKeyId)
|
||||||
RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID)
|
RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID)
|
||||||
If RequestRow NE '' then
|
If RequestRow NE '' then
|
||||||
Procedure = RequestRow<PROC_QUEUE.PROC_NAME$>
|
Procedure = RequestRow<PROC_QUEUE.PROC_NAME$>
|
||||||
|
Procedure = UCase(Procedure)
|
||||||
Params = RequestRow<PROC_QUEUE.PARAMS$>
|
Params = RequestRow<PROC_QUEUE.PARAMS$>
|
||||||
If Procedure NE '' then
|
If Procedure NE '' then
|
||||||
Dim ProcParams(11)
|
Dim ProcParams(12)
|
||||||
For each Param in Params using @VM setting pPos
|
For each Param in Params using @VM setting pPos
|
||||||
ProcParams(pPos) = Param
|
ProcParams(pPos) = Param
|
||||||
Next Param
|
Next Param
|
||||||
NumArguments = DCount(Params, @VM)
|
NumArguments = DCount(Params, @VM)
|
||||||
|
|
||||||
Begin Case
|
Begin Case
|
||||||
Case NumArguments EQ 0 ; Call @Procedure()
|
Case NumArguments EQ 0 ; Call @Procedure()
|
||||||
Case NumArguments EQ 1 ; Call @Procedure(ProcParams(1))
|
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.')
|
Error_Services('Add', 'Error in ':Service:' service. More than 11 arguments are not currently supported.')
|
||||||
End Case
|
End Case
|
||||||
end
|
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
|
end else
|
||||||
RequestRow<PROC_QUEUE.LAST_ATTEMPT_DTM$> = DateTime()
|
LogData<6> = 'Success'
|
||||||
RequestRow<PROC_QUEUE.ERROR$> = Error_Services('GetMessage')
|
|
||||||
Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, False$) ; // This call will release the lock
|
|
||||||
end
|
end
|
||||||
end else
|
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||||
// Empty request, so delete it from the queue
|
|
||||||
Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) ; // This call will release the lock
|
|
||||||
end
|
end
|
||||||
|
Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$) ; // This call should release the lock
|
||||||
|
Unlock hProcQueue, RequestKeyID else Null
|
||||||
end
|
end
|
||||||
Repeat
|
Repeat
|
||||||
end
|
end
|
||||||
@ -258,4 +294,3 @@ return
|
|||||||
/// Internal GoSubs
|
/// Internal GoSubs
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user