modified ProcessProcedureQueue to mark requests as queued and only re-queue them if they have been queued for over ten minutes

This commit is contained in:
Infineon\StieberD
2025-06-25 15:35:54 -07:00
parent 38e7b6e276
commit c6910c14c2
5 changed files with 69 additions and 51 deletions

View File

@ -55,7 +55,7 @@ Service CreateLotEvent(LotId, EventDateTime, EventType=EVENT_TYPES, EventNote, E
NewEventRec<LOT_EVENT_SEQUENCE$> = NewEventSequence
Database_Services('WriteDataRow', 'LOT_EVENT', NewEventId, NewEventRec)
If Error_Services('NoError') then
Service_Services('PostProcedure', 'LOT_EVENT_SERVICES', 'SetLatestLotEvent':@VM:LotId:@VM:NewEventId, True$)
Service_Services('PostProcedure', 'LOT_EVENT_SERVICES', 'SetLatestLotEvent':@VM:LotId:@VM:NewEventId)
end else
ErrorMessage = 'Error creating new event : ' : Error_Services('GetMessage')
end
@ -169,4 +169,3 @@ InitEventLog:
return

View File

@ -41,7 +41,7 @@ Common /ServiceServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unuse
Declare function Service_Services, Memory_Services, SRP_List, SRP_FastArray, SRP_Array, Database_Services, Datetime
Declare function GetTickCount, SRP_Decode, RTI_CreateGuid, UCase, Environment_services, Logging_Services,
Declare function SRP_TCPClient
Declare function SRP_TCPClient, SRP_Datetime
Declare subroutine Service_Services, Memory_Services, SRP_List, SRP_FastArray, RList, Set_Status, Database_Services
Declare Subroutine Yield, WinYield, Sleepery, Btree.Extract, Logging_Services, obj_Notes, SRP_TCPClient
@ -172,18 +172,35 @@ Service ProcessProcedureQueue()
ServerIP = Environment_Services('GetApplicationRootIP')
ServerPort = Environment_Services('GetServiceManagerPort')
Convert '\' to '' in ServerIP
Open 'PROC_QUEUE' to hProcQueue then
Open 'PROC_QUEUE2' to hProcQueue then
Select hProcQueue
EOF = False$
Loop
ReadNext RequestKeyID else EOF = True$
Until EOF
SendRequest = True$
Read RequestRec from hProcQueue, RequestKeyID then
InQueue = RequestRec<PROC_QUEUE.IN_QUEUE$>
If InQueue then
QueuedDtm = RequestRec<PROC_QUEUE.QUEUED_DTM$>
If QueuedDtm GT SRP_Datetime('AddMinutes', Datetime(), -10) then
SendRequest = False$
end
end
end
If SendRequest then
TcpClientHandle = 0
If SRP_TcpClient(TcpClientHandle, 'CONNECT', ServerIP, ServerPort) then
RequestRec<PROC_QUEUE.IN_QUEUE$> = True$
RequestRec<PROC_QUEUE.QUEUED_DTM$> = Datetime()
Write RequestRec on hProcQueue, RequestKeyID then
Command = 'RUN SERVICE_SERVICES "ProcessRequest", ':Quote(RequestKeyID)
SRP_TcpClient(TcpClientHandle, 'SEND_SES', Command)
end
SRP_TcpClient(TcpClientHandle, 'CLOSE_SES')
end
end
Repeat
end
Unlock hSysLists, ServiceKeyID else Null
@ -198,8 +215,8 @@ Service ProcessRequest(RequestKeyID)
DeleteRequest = True$
Server = Environment_Services('GetServer')
Done = True$
If RowExists('PROC_QUEUE', RequestKeyID) then
RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID)
If RowExists('PROC_QUEUE2', RequestKeyID) then
RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE2', RequestKeyID)
If RequestRow NE '' then
Procedure = RequestRow<PROC_QUEUE.PROC_NAME$>
Procedure = UCase(Procedure)
@ -244,7 +261,7 @@ Service ProcessRequest(RequestKeyID)
RequestRow<PROC_QUEUE.NUM_ATTEMPTS$> = NumAttempts
RequestRow<PROC_QUEUE.LAST_ATTEMPT_DTM$> = Datetime()
RequestRow<PROC_QUEUE.ERROR$> = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode
Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyId, RequestRow, True$, False$, False$)
Database_Services('WriteDataRow', 'PROC_QUEUE2', RequestKeyId, RequestRow, True$, False$, False$)
end else
// Notify OI_SYSADMIN group
Recipients = ''
@ -302,7 +319,7 @@ Service ProcessRequest(RequestKeyID)
obj_Notes('Create',Parms)
end
If DeleteRequest then
Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$)
Database_Services('DeleteDataRow', 'PROC_QUEUE2', RequestKeyId, True$, False$)
end
end
end
@ -315,32 +332,13 @@ Service PostProcedure(ProcedureName, Params, Critical=BOOLEAN)
If Critical EQ '' then Critical = True$
PostToQueue = True$
If (ProcedureName NE '') then
If Not(Critical) then
// Check if there is already a matching request in the queue before posting another one.
Query = 'PROC_NAME':@VM:ProcedureName:@FM
Query := 'PARAMS':@VM:Params:@FM
Open 'DICT.PROC_QUEUE' to hDict then
Keys = ''
Option = 'E'
Flag = ''
Btree.Extract(Query, 'PROC_QUEUE', hDict, Keys, Option, Flag)
If Flag EQ 0 then
If Keys NE '' then PostToQueue = False$
end else
Error_Services('Add', 'Error in ':Service:' service. Error calling Btree.Extract.')
end
end else
Error_Services('Add', 'Error in ':Service:' service. Error opening DICT.PROC_QUEUE.')
end
end
If PostToQueue then
RequestKeyID = RTI_CreateGUID()
RequestRow = ''
RequestRow<PROC_QUEUE.PROC_NAME$> = ProcedureName
RequestRow<PROC_QUEUE.PARAMS$> = Params
RequestRow<PROC_QUEUE.ENTRY_DTM$> = Datetime()
Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, False$)
end
RequestRow<PROC_QUEUE.IN_QUEUE$> = False$
Database_Services('WriteDataRow', 'PROC_QUEUE2', RequestKeyID, RequestRow, True$, False$, False$)
end else
Error_Services('Add', 'Error in ':Service:' service. Null ProcedureName passed in.')
end

View File

@ -0,0 +1,19 @@
compile insert PROC_QUEUE2_EQUATES
/*----------------------------------------
Author : Table Create Insert Routine
Written : 25/06/2025
Description : Insert for Table PROC_QUEUE2
----------------------------------------*/
#ifndef __PROC_QUEUE2_EQUATES__
#define __PROC_QUEUE2_EQUATES__
equ PROC_QUEUE2.PROC_NAME$ to 1
equ PROC_QUEUE2.PARAMS$ to 2
equ PROC_QUEUE2.LAST_ATTEMPT_DTM$ to 3
equ PROC_QUEUE2.ERROR$ to 4
equ PROC_QUEUE2.ENTRY_DTM$ to 5
equ PROC_QUEUE2.NUM_ATTEMPTS$ to 6
equ PROC_QUEUE2.IN_QUEUE$ to 7
equ PROC_QUEUE2.QUEUED_DTM$ to 8
#endif

View File

@ -1,7 +1,7 @@
compile insert PROC_QUEUE_EQUATES
/*----------------------------------------
Author : Table Create Insert Routine
Written : 09/12/2024
Written : 25/06/2025
Description : Insert for Table PROC_QUEUE
----------------------------------------*/
#ifndef __PROC_QUEUE_EQUATES__
@ -13,7 +13,7 @@ compile insert PROC_QUEUE_EQUATES
equ PROC_QUEUE.ERROR$ to 4
equ PROC_QUEUE.ENTRY_DTM$ to 5
equ PROC_QUEUE.NUM_ATTEMPTS$ to 6
equ PROC_QUEUE.IN_QUEUE$ to 7
equ PROC_QUEUE.QUEUED_DTM$ to 8
#endif

View File

@ -1,7 +1,7 @@
compile insert PROC_QUEUE_FAILED_EQUATES
/*----------------------------------------
Author : Table Create Insert Routine
Written : 06/06/2025
Written : 25/06/2025
Description : Insert for Table PROC_QUEUE_FAILED
----------------------------------------*/
#ifndef __PROC_QUEUE_FAILED_EQUATES__
@ -9,9 +9,11 @@ compile insert PROC_QUEUE_FAILED_EQUATES
equ PROC_QUEUE_FAILED.PROC_NAME$ to 1
equ PROC_QUEUE_FAILED.PARAMS$ to 2
equ PROC_QUEUE_FAILED.COMP_DTM$ to 3
equ PROC_QUEUE_FAILED.LAST_ATTEMPT_DTM$ to 3
equ PROC_QUEUE_FAILED.ERROR$ to 4
equ PROC_QUEUE_FAILED.ENTRY_DTM$ to 5
equ PROC_QUEUE_FAILED.NUM_ATTEMPTS$ to 6
equ PROC_QUEUE_FAILED.IN_QUEUE$ to 7
equ PROC_QUEUE_FAILED.QUEUED_DTM$ to 8
#endif