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:
@ -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
|
||||
|
||||
|
||||
|
@ -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<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
|
||||
@ -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
|
||||
RequestKeyID = RTI_CreateGUID()
|
||||
RequestRow = ''
|
||||
RequestRow<PROC_QUEUE.PROC_NAME$> = ProcedureName
|
||||
RequestRow<PROC_QUEUE.PARAMS$> = Params
|
||||
RequestRow<PROC_QUEUE.ENTRY_DTM$> = Datetime()
|
||||
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
|
||||
|
Reference in New Issue
Block a user