Running NAS with Job Queue will start a timer to process Job Queue Entries every two seconds. In the original code the Timer is disabled before checking the Job Queue Entries and then enabled again after the process. If NAS will not be able to read the Job Queue Entry then the function will exit without enabling the Timer and nothing will be processed.
The original code in Codeunit 448 is
[code htmlscript=”false”]HandleRequest()
JobQueueSetup.GET;
IF NOT JobQueueSetup."Job Queue Active" THEN
EXIT;
NavTimer.Enabled := FALSE;
ThisSessionIsActive := UpdateJobQueueSession(JobQueueEntry,FALSE);
…
CleanUpJobQueue;
COMMIT;
NavTimer.Enabled := TRUE;[/code]
I suggest that you will find a suitable period of time where everything in the Queue should be processed and change the behaviour. Do not disable the timer, just change the interval. Here I change the interval to five minutes.
The replacement code would then be
[code htmlscript=”false”]HandleRequest()
JobQueueSetup.GET;
IF NOT JobQueueSetup."Job Queue Active" THEN
EXIT;
NavTimer.Enabled := FALSE;
NavTimer.Interval := 5 * 60 * 1000; // 5 min
NavTimer.Enabled := TRUE;
ThisSessionIsActive := UpdateJobQueueSession(JobQueueEntry,FALSE);
…
CleanUpJobQueue;
COMMIT;
NavTimer.Enabled := FALSE;
NavTimer.Interval := 2 * 1000; // 2 sec.
NavTimer.Enabled := TRUE;[/code]
I didn’t get your target.
“If NAS will not be able to read the Job Queue Entry then the function will exit without enabling the Timer and nothing will be processed.”
I thought that Navision will try again with the code at last line (after 2 sec):
COMMIT;
CleanUpJobQueue;
COMMIT;
NavTimer.Enabled := TRUE;
In case of an error then the codeunit stops and the timer with it.
This looks very useful but unfortunately the code for Nav 2016 is significantly different but the system suffers from the same issues. Trying to find a solution but not having any joy – any ideas, please?
Hi Craig
The reason for the TryFunction is to catch a deadlock that has been crashing the job queue. Put that part into a dedicated Codeunit and use the Success := CODEUNIT.RUN to trap the error.
Thanks very much Gunnar – we will give that a go and see if it stops our queue from crashing.
Best wishes,
Craig
I have the same error with nav 2018. While I wrote some codes in codeunit and run it with report on job queue. I deleted the job page and recreated it which it work fine but displayed the same error message of deadlock. Where can I write the solution code, Thanks