From c6910c14c2846ca99ae1f3e9b16b22924d60f0e4 Mon Sep 17 00:00:00 2001 From: "Infineon\\StieberD" Date: Wed, 25 Jun 2025 15:35:54 -0700 Subject: [PATCH] modified ProcessProcedureQueue to mark requests as queued and only re-queue them if they have been queued for over ten minutes --- LSL2/STPROC/LOT_EVENT_SERVICES.txt | 3 +- LSL2/STPROC/SERVICE_SERVICES.txt | 74 ++++++++++---------- LSL2/STPROCINS/PROC_QUEUE2_EQUATES.txt | 19 +++++ LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt | 8 +-- LSL2/STPROCINS/PROC_QUEUE_FAILED_EQUATES.txt | 16 +++-- 5 files changed, 69 insertions(+), 51 deletions(-) create mode 100644 LSL2/STPROCINS/PROC_QUEUE2_EQUATES.txt diff --git a/LSL2/STPROC/LOT_EVENT_SERVICES.txt b/LSL2/STPROC/LOT_EVENT_SERVICES.txt index a6a9b72..01eec8e 100644 --- a/LSL2/STPROC/LOT_EVENT_SERVICES.txt +++ b/LSL2/STPROC/LOT_EVENT_SERVICES.txt @@ -55,7 +55,7 @@ Service CreateLotEvent(LotId, EventDateTime, EventType=EVENT_TYPES, EventNote, E NewEventRec = 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 - diff --git a/LSL2/STPROC/SERVICE_SERVICES.txt b/LSL2/STPROC/SERVICE_SERVICES.txt index dabd46a..9979d0d 100644 --- a/LSL2/STPROC/SERVICE_SERVICES.txt +++ b/LSL2/STPROC/SERVICE_SERVICES.txt @@ -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 @@ -171,18 +171,35 @@ Service ProcessProcedureQueue() Lock hSysLists, ServiceKeyID then ServerIP = Environment_Services('GetApplicationRootIP') ServerPort = Environment_Services('GetServiceManagerPort') - Convert '\' to '' in ServerIP - Open 'PROC_QUEUE' to hProcQueue then + Convert '\' to '' in ServerIP + + Open 'PROC_QUEUE2' to hProcQueue then Select hProcQueue EOF = False$ Loop ReadNext RequestKeyID else EOF = True$ Until EOF - TcpClientHandle = 0 - If SRP_TcpClient(TcpClientHandle, 'CONNECT', ServerIP, ServerPort) then - Command = 'RUN SERVICE_SERVICES "ProcessRequest", ':Quote(RequestKeyID) - SRP_TcpClient(TcpClientHandle, 'SEND_SES', Command) - SRP_TcpClient(TcpClientHandle, 'CLOSE_SES') + SendRequest = True$ + Read RequestRec from hProcQueue, RequestKeyID then + InQueue = RequestRec + If InQueue then + QueuedDtm = RequestRec + 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 = True$ + RequestRec = 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 @@ -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 Procedure = UCase(Procedure) @@ -244,7 +261,7 @@ Service ProcessRequest(RequestKeyID) RequestRow = NumAttempts RequestRow = Datetime() RequestRow = '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 = ProcedureName - RequestRow = Params - RequestRow = Datetime() - Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyID, RequestRow, True$, False$, False$) - end + RequestKeyID = RTI_CreateGUID() + RequestRow = '' + RequestRow = ProcedureName + RequestRow = Params + RequestRow = Datetime() + RequestRow = 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 diff --git a/LSL2/STPROCINS/PROC_QUEUE2_EQUATES.txt b/LSL2/STPROCINS/PROC_QUEUE2_EQUATES.txt new file mode 100644 index 0000000..8d00a6d --- /dev/null +++ b/LSL2/STPROCINS/PROC_QUEUE2_EQUATES.txt @@ -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 diff --git a/LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt b/LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt index d15fd37..ea062bb 100644 --- a/LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt +++ b/LSL2/STPROCINS/PROC_QUEUE_EQUATES.txt @@ -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__ @@ -12,8 +12,8 @@ compile insert PROC_QUEUE_EQUATES equ PROC_QUEUE.LAST_ATTEMPT_DTM$ to 3 equ PROC_QUEUE.ERROR$ to 4 equ PROC_QUEUE.ENTRY_DTM$ to 5 - equ PROC_QUEUE.NUM_ATTEMPTS$ to 6 + equ PROC_QUEUE.NUM_ATTEMPTS$ to 6 + equ PROC_QUEUE.IN_QUEUE$ to 7 + equ PROC_QUEUE.QUEUED_DTM$ to 8 #endif - - diff --git a/LSL2/STPROCINS/PROC_QUEUE_FAILED_EQUATES.txt b/LSL2/STPROCINS/PROC_QUEUE_FAILED_EQUATES.txt index a001849..48d3511 100644 --- a/LSL2/STPROCINS/PROC_QUEUE_FAILED_EQUATES.txt +++ b/LSL2/STPROCINS/PROC_QUEUE_FAILED_EQUATES.txt @@ -1,17 +1,19 @@ 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__ #define __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.ERROR$ to 4 - equ PROC_QUEUE_FAILED.ENTRY_DTM$ to 5 - equ PROC_QUEUE_FAILED.NUM_ATTEMPTS$ to 6 + equ PROC_QUEUE_FAILED.PROC_NAME$ to 1 + equ PROC_QUEUE_FAILED.PARAMS$ to 2 + 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